Overview
Vector3 is a double-precision 3-component vector with x, y, and z components. It is used throughout Aspose.3D for positions, directions, normals, and scale values. All arithmetic operations return new Vector3 instances; the original is not mutated.
Constructor
| Signature | Description |
|---|
Vector3() | Constructs the zero vector (0, 0, 0) |
Vector3(double x, double y, double z) | Constructs from three components |
Vector3(Vector3 other) | Copy constructor |
Public Fields
Vector3 uses public fields for component access (not getter/setter methods):
| Field | Type | Access | Description |
|---|
x | double | v.x | X component |
y | double | v.y | Y component |
z | double | v.z | Z component |
Computed Properties
| Name | Type | Getter | Description |
|---|
length | double | getLength() | Euclidean length (sqrt(x^2+y^2+z^2)), read-only |
length2 | double | getLength2() | Squared length, read-only; cheaper than getLength() when only comparison is needed |
Static Fields
| Field | Type | Description |
|---|
ZERO | Vector3 | Vector3(0, 0, 0) |
ONE | Vector3 | Vector3(1, 1, 1) |
UNIT_X | Vector3 | Vector3(1, 0, 0) |
UNIT_Y | Vector3 | Vector3(0, 1, 0) |
UNIT_Z | Vector3 | Vector3(0, 0, 1) |
Methods
| Method | Return Type | Description |
|---|
set(double x, double y, double z) | void | Sets all three components in place |
dot(Vector3 rhs) | double | Dot product with another Vector3 |
cross(Vector3 rhs) | Vector3 | Cross product – returns a vector perpendicular to both operands |
normalize() | Vector3 | Returns a unit-length copy; returns zero vector if length is zero |
angleBetween(Vector3 dir) | double | Angle in radians between this vector and dir |
angleBetween(Vector3 dir, Vector3 up) | double | Signed angle in radians projected onto the plane defined by up |
sin() | Vector3 | Component-wise sine |
cos() | Vector3 | Component-wise cosine |
compareTo(Vector3 other) | int | Lexicographic comparison: returns -1, 0, or 1 |
Vector3.parse(String s) | Vector3 | Static. Parses "x y z" string representation |
Example
See Also