com.badlogic.gdx.math.collision
Class Ray

java.lang.Object
  extended by com.badlogic.gdx.math.collision.Ray
All Implemented Interfaces:
Serializable

public class Ray
extends Object
implements Serializable

Encapsulates a ray having a starting position and a unit length direction.

Author:
[email protected]
See Also:
Serialized Form

Field Summary
 Vector3 direction
           
 Vector3 origin
           
 
Constructor Summary
Ray(Vector3 origin, Vector3 direction)
          Constructor, sets the starting position of the ray and the direction.
 
Method Summary
 Ray cpy()
           
 Vector3 getEndPoint(float distance)
          Deprecated. Use getEndPoint(Vector3, float) instead. Returns the endpoint given the distance. This is calculated as startpoint + distance * direction.
 Vector3 getEndPoint(Vector3 out, float distance)
          Returns the endpoint given the distance.
 Ray mul(Matrix4 matrix)
          Multiplies the ray by the given matrix.
 Ray set(float x, float y, float z, float dx, float dy, float dz)
          Sets this ray from the given starting position and direction.
 Ray set(Ray ray)
          Sets the starting position and direction from the given ray
 Ray set(Vector3 origin, Vector3 direction)
          Sets the starting position and the direction of this ray.
 String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

origin

public final Vector3 origin

direction

public final Vector3 direction
Constructor Detail

Ray

public Ray(Vector3 origin,
           Vector3 direction)
Constructor, sets the starting position of the ray and the direction.

Parameters:
origin - The starting position
direction - The direction
Method Detail

cpy

public Ray cpy()
Returns:
a copy of this ray.

getEndPoint

@Deprecated
public Vector3 getEndPoint(float distance)
Deprecated. Use getEndPoint(Vector3, float) instead. Returns the endpoint given the distance. This is calculated as startpoint + distance * direction.

Parameters:
distance - The distance from the end point to the start point.
Returns:
The end point

getEndPoint

public Vector3 getEndPoint(Vector3 out,
                           float distance)
Returns the endpoint given the distance. This is calculated as startpoint + distance * direction.

Parameters:
out - The vector to set to the result
distance - The distance from the end point to the start point.
Returns:
The out param

mul

public Ray mul(Matrix4 matrix)
Multiplies the ray by the given matrix. Use this to transform a ray into another coordinate system.

Parameters:
matrix - The matrix
Returns:
This ray for chaining.

toString

public String toString()

Overrides:
toString in class Object

set

public Ray set(Vector3 origin,
               Vector3 direction)
Sets the starting position and the direction of this ray.

Parameters:
origin - The starting position
direction - The direction
Returns:
this ray for chaining

set

public Ray set(float x,
               float y,
               float z,
               float dx,
               float dy,
               float dz)
Sets this ray from the given starting position and direction.

Parameters:
x - The x-component of the starting position
y - The y-component of the starting position
z - The z-component of the starting position
dx - The x-component of the direction
dy - The y-component of the direction
dz - The z-component of the direction
Returns:
this ray for chaining

set

public Ray set(Ray ray)
Sets the starting position and direction from the given ray

Parameters:
ray - The ray
Returns:
This ray for chaining


Copyright © 2014. All Rights Reserved.