DirectX Media for Animation Java Reference |
![]() Previous |
![]() Classes |
![]() Index |
![]() Next |
public class Vector2Bvr extends Behavior { // Fields public static Vector2Bvr xVector2; public static Vector2Bvr yVector2; public static Vector2Bvr zeroVector2; // Methods public Vector2Bvr div(NumberBvr scalar); public NumberBvr getRho(); public NumberBvr getTheta(); public NumberBvr getX(); public NumberBvr getY(); public NumberBvr length(); public NumberBvr lengthSquared(); public Vector2Bvr mul(NumberBvr scalar); public Vector2Bvr neg(); public Vector2Bvr normalize(); public Vector2Bvr transform(Transform2Bvr xf); public static Vector2Bvr add(Vector2Bvr v1, Vector2Bvr v2); public static Vector2Bvr bSpline(int degree, NumberBvr[] knots, Vector2Bvr[] control_elements, NumberBvr[] weights); public static Vector2Bvr derivative(Vector2Bvr vec); public static NumberBvr dot(Vector2Bvr v1, Vector2Bvr v2); public static Vector2Bvr integral(Vector2Bvr vec); public static Vector2Bvr newUninitBvr(); public static Vector2Bvr sub(Vector2Bvr v1, Vector2Bvr v2); public static Vector2Bvr vector2Polar(NumberBvr theta, NumberBvr rho); public static Vector2Bvr vector2Xy(NumberBvr x, NumberBvr y); }
Creates an object that represents a two-dimensional vector behavior. At any given time, the value of the behavior is a direction and length (magnitude), specified as a pair of coordinate values given as either Cartesian coordinates (x, y) or polar coordinates (theta, rho). The direction of the vector is parallel to the ray that starts at the origin and passes through the point specified by the vector's coordinates, and the length is the distance between the origin and the point.
Because coordinate values are number behaviors (NumberBvr objects), the direction and length of the vector behavior may change over time as the number behaviors change. For more information about behaviors, see the Behavior class.
public Vector2Bvr div(NumberBvr scalar);Creates a new two-dimensional vector behavior that points in the same direction as the original vector but has a length that has been divided by scalar.
Return Value:
Returns the Vector2Bvr object.
Parameter Description scalar A NumberBvr object. See Also: mul
public NumberBvr getRho();Returns the NumberBvr that is the length of the vector.
Return Value:
Returns the NumberBvr object.
See Also: getTheta, vector2Polar
public NumberBvr getTheta();Returns the NumberBvr object that is the counter-clockwise angular rotation, in radians, of the vector from the positive x-ray.
Return Value:
Returns the NumberBvr object.
See Also: getRho, vector2Polar
public NumberBvr getX();Creates a number behavior that represents the x coordinate of this vector behavior.
Return Value:
Returns the NumberBvr object.
public NumberBvr getY();Creates a number behavior that represents the y coordinate of this vector behavior.
Return Value:
Returns the NumberBvr object.
public NumberBvr length();Creates a number behavior that represents the length of a vector behavior.
Return Value:
Returns the NumberBvr object.
See Also: lengthSquared
public NumberBvr lengthSquared();Creates a number behavior that represents the length of a vector behavior squared.
Return Value:
Returns the NumberBvr object.
Remarks:
It is slightly more efficient to calculate lengthSquared than length.
See Also: length
public Vector2Bvr mul(NumberBvr scalar);Creates a new two-dimensional vector behavior that points in the same direction as the original vector but has a length that has been multiplied by scalar.
Return Value:
Returns the Vector2Bvr object.
Parameter Description scalar A NumberBvr object. See Also: div
public Vector2Bvr neg();Creates a new two-dimensional vector behavior that has the same length as the original vector, but points in the opposite direction.
Return Value:
Returns the Vector2Bvr object.
public Vector2Bvr normalize();Creates a normalized, two-dimensional vector behavior. The normalized vector has the same direction as the original vector, but the length is 1.
Return Value:
Returns the Vector2Bvr object.
public Vector2Bvr transform(Transform2Bvr xf);Creates a new two-dimensional vector behavior that is the result of applying the given transformation to the original vector. The translation elements of the transformation are ignored; translation does not apply to vectors.
Return Value:
Returns the Vector2Bvr object.
Parameter Description xf A Transform2Bvr object. Remarks:
This attribute composes values.
public static Vector2Bvr add(Vector2Bvr v1, Vector2Bvr v2);Creates a two-dimensional vector behavior that is the vector-valued sum of the two vectors.
Return Value:
Returns the Vector2Bvr object.
Parameter Description v1 and v2 The Vector2Bvr objects. See Also: sub
public static Vector2Bvr bSpline(int degree, NumberBvr[] knots, Vector2Bvr[] control_elements, NumberBvr[] weights);Creates a Vector2Bvr object that that defines a B-spline curve from which individual vector behaviors, representing positions on the curve, can be evaluated. The shape of the curve depends on the mathematical degree of curve and whether weights are provided.
A B-spline with weights is rational, and without weights is non-rational (polynomial). The non-rational variety assumes that #points = numKnots - degree + 1. The knots represent known positions along the curve, and the control points define the direction and shape of the curve as it passes from one knot to the next.
Given a degree of curve d and a number of knots k, a position on the curve can be evaluated for any value in the range knotd to knotk-d+1. For example, for a degree 2 curve, the valid range is from the second knot to the next to the last knot, inclusive.
The returned Vector2Bvr behavior is the evaluation of the spline curve according to time. By default, the spline parameter advances at a rate of one unit per second. To control the evaluation of the curve, use the substituteTime method. Times outside the valid range are clamped to the values at the endpoints of the spline.
Return Value:
Returns the Vector2Bvr object.
Parameter Description degree A number representing the mathematical degree of the B-spline to evaluate. Must be 1, 2, or 3. knots An array of NumberBvr objects representing the knots used to calculate the B-spline. control_elements An array of Vector2Bvr objects representing the control elements used to calculate the B-spline. weights An array of NumberBvr objects representing the weights used to calculate the rational B-spline. There must be the same number of weights as control elements. For non-rational B-splines, the value of weights is null.
public static Vector2Bvr derivative(Vector2Bvr vec);Creates a new, two-dimensional vector behavior that is the instantaneous derivative (rate of change) of the given vector behavior. For example, a constant vector behavior yields a constant derivative of [0 0], and vector2Xy(time, 0) (without any additional time substitutions) yields a constant derivative vector of [1 0].
Return Value:
Returns the Vector2Bvr object.
Parameter Description vec A Vector2Bvr object.
public static NumberBvr dot(Vector2Bvr v1, Vector2Bvr v2);Creates a number behavior that represent the "dot product" of the given vectors. The dot product is the product of the lengths of the vectors and the cosine of the angle between them.
Return Value:
Returns the NumberBvr object.
Parameter Description v1 and v2 The Vector2Bvr objects.
public static Vector2Bvr integral(Vector2Bvr vec);Creates an two-dimensional vector that represents the sum of the all values of vec from the given start time to the present.
Return Value:
Returns the Vector2Bvr object.
Parameter Description a The Vector2Bvr object.
public static Vector2Bvr newUninitBvr();This method allows you to refer to an Vector2Bvr behavior before that behavior has been defined. With this method you can create the behavior and use it in the definition of other behaviors, but not actually define its contents until some later point. (This is accomplished with the init method, which is available on all behaviors.) The system generates a run-time error if you initialize a non-uninitialized behavior, initialize an uninitialized behavior that has already been initialized, or run an initialized behavior that has not yet been initialized.
Return Value:
Returns the Vector2Bvr object.
public static Vector2Bvr sub(Vector2Bvr v1, Vector2Bvr v2);Creates a two-dimensional vector behavior. The direction and length of the vector are calculated by subtracting the coordinates of v2 from the corresponding coordinates of v1.
Return Value:
Returns the Vector2Bvr object.
Parameter Description v1 and v2 The Vector2Bvr objects. See Also: add
public static Vector2Bvr vector2Polar(NumberBvr theta, NumberBvr rho);Creates a two-dimensional vector behavior, having a direction and length as specified by the given polar coordinates.
Return Value:
Returns the Vector2Bvr object.
Parameter Description theta The NumberBvr object that is the counter-clockwise angle of the vector, in radians, from the positive x-ray. rho The NumberBvr object that is the length of the vector. See Also: vector2Xy
public static Vector2Bvr vector2Xy(NumberBvr x, NumberBvr y);Creates a two-dimensional vector behavior, having a direction and length as specified by the given Cartesian coordinates.
Return Value:
Returns the Vector2Bvr object.
Parameter Description x The NumberBvr object specifying the distance along the x-axis from the origin to a point. y NumberBvr object specifying the distance along the y-axis. See Also: vector2Polar
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.