libgdx API

com.badlogic.gdx.math
Class CatmullRomSpline

java.lang.Object
  extended by com.badlogic.gdx.math.CatmullRomSpline
All Implemented Interfaces:
java.io.Serializable

public class CatmullRomSpline
extends java.lang.Object
implements java.io.Serializable

Encapsulates a catmull rom spline with n control points, n >= 4. For more information on this type of spline see http://www.mvps.org/directx/articles/catmull/.

Author:
badlogicgames@gmail.com
See Also:
Serialized Form

Constructor Summary
CatmullRomSpline()
           
 
Method Summary
 void add(Vector3 point)
          Adds a new control point
 java.util.List<Vector3> getControlPoints()
           
 java.util.List<Vector3> getPath(int numPoints)
          Returns a path, between every two control points numPoints are generated and the control points themselves are added too.
 void getPath(Vector3[] points, int numPoints)
          Returns a path, between every two control points numPoints are generated and the control points themselves are added too.
 java.util.List<Vector3> getTangentNormals(int numPoints, java.util.List<Vector3> up)
           
 java.util.List<Vector3> getTangentNormals(int numPoints, Vector3 up)
          Returns the tangent's normals using the tangent and provided up vector doing a cross product.
 java.util.List<Vector3> getTangentNormals2D(int numPoints)
          Returns all tangent's normals in 2D space for the points in a path.
 java.util.List<Vector3> getTangents(int numPoints)
          Returns all tangents for the points in a path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CatmullRomSpline

public CatmullRomSpline()
Method Detail

add

public void add(Vector3 point)
Adds a new control point

Parameters:
point - the point

getControlPoints

public java.util.List<Vector3> getControlPoints()
Returns:
all control points

getPath

public java.util.List<Vector3> getPath(int numPoints)
Returns a path, between every two control points numPoints are generated and the control points themselves are added too. The first and the last controlpoint are omitted. if there's less than 4 controlpoints an empty path is returned.

Parameters:
numPoints - number of points returned for a segment
Returns:
the path

getPath

public void getPath(Vector3[] points,
                    int numPoints)
Returns a path, between every two control points numPoints are generated and the control points themselves are added too. The first and the last controlpoint are omitted. if there's less than 4 controlpoints an empty path is returned.

Parameters:
points - the array of Vector3 instances to store the path in
numPoints - number of points returned for a segment

getTangents

public java.util.List<Vector3> getTangents(int numPoints)
Returns all tangents for the points in a path. Same semantics as getPath.

Parameters:
numPoints - number of points returned for a segment
Returns:
the tangents of the points in the path

getTangentNormals2D

public java.util.List<Vector3> getTangentNormals2D(int numPoints)
Returns all tangent's normals in 2D space for the points in a path. The controlpoints have to lie in the x/y plane for this to work. Same semantics as getPath.

Parameters:
numPoints - number of points returned for a segment
Returns:
the tangents of the points in the path

getTangentNormals

public java.util.List<Vector3> getTangentNormals(int numPoints,
                                                 Vector3 up)
Returns the tangent's normals using the tangent and provided up vector doing a cross product.

Parameters:
numPoints - number of points per segment
up - up vector
Returns:
a list of tangent normals

getTangentNormals

public java.util.List<Vector3> getTangentNormals(int numPoints,
                                                 java.util.List<Vector3> up)

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)