public class Vector2Bvr extends Behavior { // Methods public Vector2Bvr div(NumberBvr scalar); public NumberBvr getPolarCoordAngle(); public NumberBvr getPolarCoordLength(); public NumberBvr getX(); public NumberBvr getY(); public NumberBvr length(); public NumberBvr lengthSquared(); public Vector2Bvr mul(NumberBvr scalar); public Vector2Bvr normalize(); public Vector2Bvr transform(Transform2Bvr xf); public static Vector2Bvr newUninitBvr(); }
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 (XYangle, length). 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.
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.
public Vector2Bvr div(
NumberBvr scalar
);
Returns the Vector2Bvr object.
Creates a number behavior that represents the counter-clockwise angular displacement, in radians, relative to the positive x-axis, of the vector behavior. The range is [-Pi, +Pi].
public NumberBvr getPolarCoordAngle( );
Returns the NumberBvr object.
getPolarCoordLength, vector2Polar
Creates a number behavior that is the length of the vector.
public NumberBvr getPolarCoordLength( );
Returns the NumberBvr object.
getPolarCoordXYAngle, vector2Polar
Creates a number behavior that represents the x coordinate of this vector behavior.
public NumberBvr getX( );
Returns the NumberBvr object.
Creates a number behavior that represents the y coordinate of this vector behavior.
public NumberBvr getY( );
Returns the NumberBvr object.
Creates a number behavior that represents the length of a vector behavior.
public NumberBvr length( );
Returns the NumberBvr object.
Creates a number behavior that represents the length of a vector behavior squared.
public NumberBvr lengthSquared( );
Returns the NumberBvr object.
It is slightly more efficient to calculate lengthSquared than length.
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.
public Vector2Bvr mul(
NumberBvr scalar
);
Returns the Vector2Bvr object.
Creates a normalized, two-dimensional vector behavior. The normalized vector has the same direction as the original vector, but the length is 1.
public Vector2Bvr normalize( );
Returns the Vector2Bvr object.
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.
public Vector2Bvr transform(
Transform2Bvr xf
);
Returns the Vector2Bvr object.
This attribute composes values.
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.
public static Vector2Bvr newUninitBvr( );
Returns the Vector2Bvr object.
The following methods are defined in the Statics class and are most relevant to objects of type Vector2Bvr.
public static Vector2Bvr add(Vector2Bvr v1, Vector2Bvr v2);
public static Vector2Bvr derivative(Vector2Bvr vec);
public static NumberBvr dot(Vector2Bvr v1, Vector2Bvr v2);
public static Vector2Bvr integral(Vector2Bvr vec);
public static Vector2Bvr neg(Vector2Bvr v1);
public static Vector2Bvr sub(Vector2Bvr v1, Vector2Bvr v2);
public static Vector2Bvr vector2(NumberBvr x, NumberBvr y);
public static Vector2Bvr vector2Polar(NumberBvr XYangle, NumberBvr length);
public static Vector2Bvr vector2PolarDegrees(double XYangle, double length);
The following fields are defined in the Statics class and are most relevant to objects of type Vector3Bvr.
public final static Vector2Bvr xVector2;
public final static Vector2Bvr yVector2;
public final static Vector2Bvr zeroVector2;
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.