Class: | Vector3D |
Parent: | Object |
The class Vector3D represents a three-dimensional vector with three Float numbers.
Create a new vector3d object. The first form is equivalent to Vector3D#new(vx), and the second form is equivalent to Vector3D#new([fx, fy, fz]).
Returns a new Vector3D object. In the first form, a zero vector is returned. In the second form, the given vector3d is duplicated. In the third form, a row vector or a column vector (with dimension 3 or larger) is converted to a vector3d. In the fourth form, a vector [fx, fy, fz] is returned.
In the first form, the vector is scaled by the numeric. In the second form, the dot (inner) product of the two vectors are returned, which is equivalent to self.dot(val).
Add two vectors element by element. Val is converted to a Vector3D if necessary.
Subtract two vectors element by element. Val is converted to a Vector3D if necessary.
Two Vector3D objects are equal if their elements are all equal. Usual caution about comparison between floating point numbers should be paid. Also consider using something like self.length < 1e-10
.
Element Reference. Returns the element at the given index (0, 1, 2 for x, y, z component, respectively). If the index is less than 0 or more than 2, an exception is thrown.
Element Assignment. Set the element at index (0, 1, 2 for x, y, z component, respectively). If index is less than 0 or more than 2, an exception is thrown.
Calculate the cross (outer) product of the two vectors. Val is converted to a Vector3D if necessary.
Calculate the dot (inner) product of the two vectors. Val is converted to a Vector3D if necessary.
See Also: Vector3D.*.
Calculate the Pythagorean length of the vector. Note that this method is not an alias of Vector3D#size, which returns 3.
See Also: Vector3D#length2.
Calculate the square of the Pythagorean length of the vector.
See Also: Vector3D#length.
Returns a unit vector with the same direction. Raises an exception when the vector is a zero vector.