pythagoras.d

## Class Ray2

• All Implemented Interfaces:
IRay2

```public class Ray2
extends Object
implements IRay2```
A ray consisting of an origin point and a unit direction vector.
• ### Field Summary

Fields
Modifier and Type Field and Description
`Vector` `direction`
The ray's unit direction vector.
`Vector` `origin`
The ray's point of origin.
• ### Constructor Summary

Constructors
Constructor and Description
`Ray2()`
Creates an empty (invalid) ray.
`Ray2(Ray2 other)`
Copy constructor.
```Ray2(Vector origin, Vector direction)```
Creates a ray with the values contained in the supplied origin point and unit direction vector.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`IVector` `direction()`
Returns a reference to the ray's unit direction vector.
`boolean` ```getIntersection(IVector center, double radius, Vector result)```
Finds the intersection between the ray and a circle with the given center and radius.
`boolean` ```getIntersection(IVector start, IVector end, double radius, Vector result)```
Finds the intersection between the ray and a capsule with the given start point, end point, and radius.
`boolean` ```getIntersection(IVector start, IVector end, Vector result)```
Finds the intersection between the ray and a line segment with the given start and end points.
`Vector` ```getNearestPoint(IVector point, Vector result)```
Computes the nearest point on the Ray to the supplied point.
`boolean` `intersects(IVector pt)`
Determines whether the ray intersects the specified point.
`IVector` `origin()`
Returns a reference to the ray's point of origin.
`Ray2` `set(IRay2 other)`
Copies the parameters of another ray.
`Ray2` ```set(IVector origin, IVector direction)```
Sets the ray parameters to the values contained in the supplied vectors.
`String` `toString()`
`Ray2` `transform(Transform transform)`
Transforms this ray.
`Ray2` ```transform(Transform transform, Ray2 result)```
Transforms this ray, placing the result in the object provided.
`Ray2` `transformLocal(Transform transform)`
Transforms this ray in-place.
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### origin

`public final Vector origin`
The ray's point of origin.
• #### direction

`public final Vector direction`
The ray's unit direction vector.
• ### Constructor Detail

• #### Ray2

```public Ray2(Vector origin,
Vector direction)```
Creates a ray with the values contained in the supplied origin point and unit direction vector.
• #### Ray2

`public Ray2(Ray2 other)`
Copy constructor.
• #### Ray2

`public Ray2()`
Creates an empty (invalid) ray.
• ### Method Detail

• #### set

`public Ray2 set(IRay2 other)`
Copies the parameters of another ray.
Returns:
a reference to this ray, for chaining.
• #### set

```public Ray2 set(IVector origin,
IVector direction)```
Sets the ray parameters to the values contained in the supplied vectors.
Returns:
a reference to this ray, for chaining.
• #### transformLocal

`public Ray2 transformLocal(Transform transform)`
Transforms this ray in-place.
Returns:
a reference to this ray, for chaining.
• #### origin

`public IVector origin()`
Description copied from interface: `IRay2`
Returns a reference to the ray's point of origin.
Specified by:
`origin` in interface `IRay2`
• #### direction

`public IVector direction()`
Description copied from interface: `IRay2`
Returns a reference to the ray's unit direction vector.
Specified by:
`direction` in interface `IRay2`
• #### transform

`public Ray2 transform(Transform transform)`
Description copied from interface: `IRay2`
Transforms this ray.
Specified by:
`transform` in interface `IRay2`
Returns:
a new ray containing the result.
• #### transform

```public Ray2 transform(Transform transform,
Ray2 result)```
Description copied from interface: `IRay2`
Transforms this ray, placing the result in the object provided.
Specified by:
`transform` in interface `IRay2`
Returns:
a reference to the result ray, for chaining.
• #### intersects

`public boolean intersects(IVector pt)`
Description copied from interface: `IRay2`
Determines whether the ray intersects the specified point.
Specified by:
`intersects` in interface `IRay2`
• #### getIntersection

```public boolean getIntersection(IVector start,
IVector end,
Vector result)```
Description copied from interface: `IRay2`
Finds the intersection between the ray and a line segment with the given start and end points.
Specified by:
`getIntersection` in interface `IRay2`
Returns:
true if the ray intersected the segment (in which case the result will contain the point of intersection), false otherwise.
• #### getIntersection

```public boolean getIntersection(IVector start,
IVector end,
Vector result)```
Description copied from interface: `IRay2`
Finds the intersection between the ray and a capsule with the given start point, end point, and radius.
Specified by:
`getIntersection` in interface `IRay2`
Returns:
true if the ray intersected the circle (in which case the result will contain the point of intersection), false otherwise.
• #### getIntersection

```public boolean getIntersection(IVector center,
Vector result)```
Description copied from interface: `IRay2`
Finds the intersection between the ray and a circle with the given center and radius.
Specified by:
`getIntersection` in interface `IRay2`
Returns:
true if the ray intersected the circle (in which case the result will contain the point of intersection), false otherwise.
• #### getNearestPoint

```public Vector getNearestPoint(IVector point,
Vector result)```
Description copied from interface: `IRay2`
Computes the nearest point on the Ray to the supplied point.
Specified by:
`getNearestPoint` in interface `IRay2`
Returns:
`result` for chaining.
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`