- Object
-
- Ray
-
public class Ray extends Object
Implementation of a ray.A ray is a vector with a start point.
- Since:
- 2.0.0
- Version:
- 3.4.0
- Author:
- William Bittle
-
-
Constructor Summary
Constructors Constructor Description Ray(double direction)
Creates a ray from the origin in the given direction.Ray(Vector2 direction)
Creates a ray from the origin in the given direction.Ray(Vector2 start, double direction)
Creates a ray from the given start point in the given direction.Ray(Vector2 start, Vector2 direction)
Creates a ray from the given start point in the given direction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getDirection()
Returns the direction of this ray in radians.Vector2
getDirectionVector()
Returns the direction.Vector2
getStart()
Returns the start point.void
setDirection(double direction)
Sets the direction of this ray in radians.void
setDirection(Vector2 direction)
Sets the direction.void
setStart(Vector2 start)
Sets the start point.String
toString()
-
-
-
Constructor Detail
-
Ray
public Ray(double direction)
Creates a ray from the origin in the given direction.- Parameters:
direction
- the direction in radians- Since:
- 3.0.2
-
Ray
public Ray(Vector2 direction)
Creates a ray from the origin in the given direction.- Parameters:
direction
- the direction
-
Ray
public Ray(Vector2 start, double direction)
Creates a ray from the given start point in the given direction.- Parameters:
start
- the start pointdirection
- the direction in radians- Since:
- 3.0.2
-
Ray
public Ray(Vector2 start, Vector2 direction)
Creates a ray from the given start point in the given direction.- Parameters:
start
- the start pointdirection
- the direction- Throws:
NullPointerException
- if start or direction is nullIllegalArgumentException
- if direction is the zero vector
-
-
Method Detail
-
setStart
public void setStart(Vector2 start)
Sets the start point.- Parameters:
start
- the start point- Throws:
NullPointerException
- if start is null
-
setDirection
public void setDirection(double direction)
Sets the direction of this ray in radians.- Parameters:
direction
- the direction in radians- Since:
- 3.0.2
-
getDirection
public double getDirection()
Returns the direction of this ray in radians.- Returns:
- double the direction in radians between [-π, π]
- Since:
- 3.0.2
-
setDirection
public void setDirection(Vector2 direction)
Sets the direction.- Parameters:
direction
- the direction; should be normalized- Throws:
NullPointerException
- if direction is nullIllegalArgumentException
- if direction is the zero vector
-
-