Vector4 — Aspose.3D FOSS for Java
Methods
Vector4 ir dubultas precizitātes 4-komponentu vektors. Tas ir glabāšanas tips režģa kontroles punktiem (kur w = 1.0 pozīcijām) un normālo datu VertexElementNormal slāņos (kur w nav izmantots).
Methods: com.aspose.threed
import com.aspose.threed.*;
Vector4 point = new Vector4(1.0, 2.0, 3.0, 1.0);Methods
| Methods | Methods |
|---|---|
Vector4() | Methods (0, 0, 0, 1) |
Vector4(double x, double y, double z, double w) | Izveido no četriem komponentiem |
Vector4(double x, double y, double z) | Izveido ar w = 1.0 |
Vector4(Vector3 v3) | Izveido no Vector3 ar w = 1.0 |
Vector4(Vector4 other) | Kopijas konstruktoru |
Publiskie lauki
Vector4 izmanto publiskos laukus komponentu piekļuvei (nevis getter/setter metodes):
| Methods | Methods | Methods | Methods |
|---|---|---|---|
x | double | v.x | X komponente |
y | double | v.y | Y komponente |
z | double | v.z | Z komponente |
w | double | v.w | W komponente (homogēnā koordināta) |
Methods
| Methods | Atgriešanas tips | Methods |
|---|---|---|
set(double x, double y, double z, double w) | void | Iestata visus četrus komponentus |
toVector3() | Vector3 | Atgriež Vector3(x, y, z) noņemot w komponents |
Methods
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