Vector4 — Aspose.3D FOSS for Java

Example

Vector4 yra dvigubo tikslumo 4 komponentų vektorius. Tai yra saugojimo tipas tinklo valdymo taškams (kur w = 1.0 padėčių) ir normalų duomenims in VertexElementNormal sluoksniuose (kur w nėra naudojamas).

Example: com.aspose.threed

import com.aspose.threed.*;

Vector4 point = new Vector4(1.0, 2.0, 3.0, 1.0);

Example

ExampleExample
Vector4()Example (0, 0, 0, 1)
Vector4(double x, double y, double z, double w)Konstruktorius iš keturių komponentų
Vector4(double x, double y, double z)Kuriama su w = 1.0
Vector4(Vector3 v3)Kuriama iš Vector3 su w = 1.0
Vector4(Vector4 other)Kopijavimo konstruktorius

Vieši laukai

Vector4 naudoja vieši laukai komponentų prieigai (ne getter/setter metodų):

ExampleExampleExampleExample
xdoublev.xX komponentas
ydoublev.yY komponentas
zdoublev.zZ komponentas
wdoublev.wW komponentas (homogeninė koordinatė)

Example

ExampleGrąžinimo tipasExample
set(double x, double y, double z, double w)voidNustato visus keturis komponentus
toVector3()Vector3Grąžina Vector3(x, y, z) pašalinant w komponentas

Example

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

Žr. taip pat

 Lietuvių