Vector3D
The Vector3D object represents a point or a location in the three-dimensional space using the Cartesian coordinates x, y, and z. As in a two-dimensional space, the x property represents the horizontal axis and the y property represents the vertical axis. In three-dimensional space, the z property represents depth. The value of the x property increases as the object moves to the right. The value of the y property increases as the object moves down. The z property increases as the object moves farther from the point of view. Using perspective projection and scaling, the object is seen to be bigger when near and smaller when farther away from the screen. As in a right-handed three-dimensional coordinate system, the positive z-axis points away from the viewer and the value of the z property increases as the object moves away from the viewer's eye. The origin point (0,0,0) of the global space is the upper-left corner of the stage.
The Vector3D object can also represent a direction, an arrow pointing from the origin of the coordinates, such as (0,0,0), to an endpoint; or a floating-point component of an RGB (Red, Green, Blue) color model.
Quaternion notation introduces a fourth element, the w property, which provides additional orientation information. For example, the w property can define an angle of rotation of a Vector3D object. The combination of the angle of rotation and the coordinates x, y, and z can determine the display object's orientation.
Can be created using method new:
Lib.Media.Geom.Vector3D.new(x, y, z, w) |
Creates an instance of a Vector3D object. |
x - (default = 0.) - The first element, such as the x coordinate. y - (default = 0.) - The second element, such as the y coordinate. z - (default = 0.) - The third element, such as the z coordinate. w - (default = 0.) - An optional element for additional data such as the angle of rotation. |
Created Vector3D object has properties:
length |
[read-only] The length, magnitude, of the current Vector3D object from the origin (0,0,0) to the object's x, y, and z coordinates. |
lengthSquared |
[read-only] The square of the length of the current Vector3D object, calculated using the x, y, and z properties. |
w |
The fourth element of a Vector3D object (in addition to the x, y, and z properties) can hold data such as the angle of rotation. |
x |
The first element of a Vector3D object, such as the x coordinate of a point in the three-dimensional space. |
y |
The second element of a Vector3D object, such as the y coordinate of a point in the three-dimensional space. |
z |
The third element of a Vector3D object, such as the z coordinate of a point in three-dimensional space. |
methods:
add(a) |
Adds the value of the x, y, and z elements of the current Vector3D object to the values of the x, y, and z elements of another Vector3D object. |
a - A Vector3D object to be added to the current Vector3D object. |
angleBetween(a, b) |
[static] Returns the angle in radians between two vectors. |
a - The first Vector3D object. b - The second Vector3D object. |
clone() |
Returns a new Vector3D object that is an exact copy of the current Vector3D object. |
|
copyFrom(sourceVector3D) |
Copies all of vector data from the source Vector3D object into the calling Vector3D object. |
sourceVector3D - The Vector3D object from which to copy the data. |
crossProduct(a) |
Returns a new Vector3D object that is perpendicular (at a right angle) to the current Vector3D and another Vector3D object. |
a - A second Vector3D object. |
decrementBy(a) |
Decrements the value of the x, y, and z elements of the current Vector3D object by the values of the x, y, and z elements of specified Vector3D object. |
a - The Vector3D object containing the values to subtract from the current Vector3D object. |
distance(pt1, pt2) |
[static] Returns the distance between two Vector3D objects. |
pt1 - A Vector3D object as the first three-dimensional point. pt2 - A Vector3D object as the second three-dimensional point. |
dotProduct(a) |
If the current Vector3D object and the one specified as the parameter are unit vertices, this method returns the cosine of the angle between the two vertices. |
a - The second Vector3D object. |
equals(toCompare, allFour) |
Determines whether two Vector3D objects are equal by comparing the x, y, and z elements of the current Vector3D object with a specified Vector3D object. |
toCompare - The Vector3D object to be compared with the current Vector3D object. allFour - (default = false) - An optional parameter that specifies whether the w property of the Vector3D objects is used in the comparison. |
incrementBy(a) |
Increments the value of the x, y, and z elements of the current Vector3D object by the values of the x, y, and z elements of a specified Vector3D object. |
a - The Vector3D object to be added to the current Vector3D object. |
nearEquals(toCompare, tolerance, allFour) |
Compares the elements of the current Vector3D object with the elements of a specified Vector3D object to determine whether they are nearly equal. |
toCompare - The Vector3D object to be compared with the current Vector3D object. tolerance - A number determining the tolerance factor. If the difference between the values of the Vector3D element specified in the toCompare parameter and the current Vector3D element is less than the tolerance number, the two values are considered nearly equal. allFour - (default = false) - An optional parameter that specifies whether the w property of the Vector3D objects is used in the comparison. |
negate() |
Sets the current Vector3D object to its inverse. |
|
normalize() |
Converts a Vector3D object to a unit vector by dividing the first three elements (x, y, z) by the length of the vector. |
|
project() |
Divides the value of the x, y, and z properties of the current Vector3D object by the value of its w property. |
|
scaleBy(s) |
Scales the current Vector3D object by a scalar, a magnitude. |
s - A multiplier (scalar) used to scale a Vector3D object. |
setTo(xa, ya, za) |
Sets the members of Vector3D to the specified values |
xa - the values to set the vector to. ya za |
subtract(a) |
Subtracts the value of the x, y, and z elements of the current Vector3D object from the values of the x, y, and z elements of another Vector3D object. |
a - The Vector3D object to be subtracted from the current Vector3D object. |
toString() |
Returns a string representation of the current Vector3D object. |
|
Created with the Personal Edition of HelpNDoc: Produce electronic books easily