Vector4 — Aspose.3D FOSS for Java
Enumerations
Vector4 je dvostruko precizni vektor s 4 komponente. To je tip pohrane za kontrolne točke mreže (gdje w = 1.0 za pozicije) i za normalne podatke u VertexElementNormal slojevima (gdje w nije korišten).
Enumerations: com.aspose.threed
import com.aspose.threed.*;
Vector4 point = new Vector4(1.0, 2.0, 3.0, 1.0);Enumerations
| Enumerations | Enumerations |
|---|---|
Vector4() | Enumerations (0, 0, 0, 1) |
Vector4(double x, double y, double z, double w) | Konstruktor iz četiri komponente |
Vector4(double x, double y, double z) | Konstruktor s w = 1.0 |
Vector4(Vector3 v3) | Konstruktor iz Vector3 s w = 1.0 |
Vector4(Vector4 other) | Konstruktor kopije |
Javna polja
Vector4 koristi javna polja za pristup komponentama (ne metode getter/setter):
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
x | double | v.x | X komponenta |
y | double | v.y | Y komponenta |
z | double | v.z | Z komponenta |
w | double | v.w | W komponenta (homogena koordinata) |
Enumerations
| Enumerations | Tip povratka | Enumerations |
|---|---|---|
set(double x, double y, double z, double w) | void | Postavlja sve četiri komponente |
toVector3() | Vector3 | Vraća a Vector3(x, y, z) odbačivanje w komponenta |
Enumerations
import com.aspose.threed.*;
Mesh mesh = new Mesh();
// Add control points (w=1.0 for positions)
mesh.getControlPoints().add(new Vector4(0.0, 0.0, 0.0, 1.0));
mesh.getControlPoints().add(new Vector4(1.0, 0.0, 0.0, 1.0));
mesh.getControlPoints().add(new Vector4(0.5, 1.0, 0.0, 1.0));
mesh.createPolygon(0, 1, 2);
// Convert to Vector3
Vector4 v4 = new Vector4(1.0, 2.0, 3.0, 1.0);
Vector3 v3 = v4.toVector3(); // Vector3(1.0, 2.0, 3.0)
// Construct from Vector3
Vector3 pos = new Vector3(5.0, 0.0, 0.0);
Vector4 homogeneous = new Vector4(pos); // w = 1.0