FVector3, FVector4 — Aspose.3D FOSS for Java
Paket: com.aspose.threed (aspose-3d-foss 26.1.0)
Example FVector family menyediakan presisi tunggal (float) alternatif untuk presisi ganda Vector tipe. Mereka digunakan secara internal oleh array data elemen vertex untuk penyimpanan kompak normal, tangent, dan koordinat UV.
Catatan: FVector2 tidak ada di edisi Java. Hanya FVector3 dan FVector4 tersedia.
FVector3
Vektor float 3-komponen presisi tunggal. Muncul dalam array data elemen vertex untuk normal dan tangent.
Example
| Example | Example |
|---|---|
FVector3() | Example (0, 0, 0) |
FVector3(float x, float y, float z) | Konstruksi dari tiga komponen |
FVector3(Vector3 v) | Konstruksi dari presisi ganda Vector3 |
Bidang Publik
FVector3 menggunakan field publik untuk mengakses komponen:
| Example | Example | Example | Example |
|---|---|---|---|
x | float | v.x | komponen X |
y | float | v.y | komponen Y |
z | float | v.z | komponen Z |
Example
| Example | Tipe Pengembalian | Example |
|---|---|---|
normalize() | FVector3 | Mengembalikan salinan dengan panjang satu unit |
cross(FVector3 rhs) | FVector3 | Produk silang |
dot(FVector3 rhs) | float | Produk titik |
FVector4
Vektor float 4-komponen presisi tunggal. Tipe penyimpanan dari VertexElementFVector data.
Example
| Example | Example |
|---|---|
FVector4() | Example (0, 0, 0, 0) |
FVector4(float x, float y, float z, float w) | Membuat dari empat komponen |
FVector4(Vector4 v) | Membuat dari presisi ganda Vector4 |
Bidang Publik
FVector4 menggunakan field publik untuk mengakses komponen:
| Example | Example | Example | Example |
|---|---|---|---|
x | float | v.x | komponen X |
y | float | v.y | komponen Y |
z | float | v.z | komponen Z |
w | float | v.w | komponen W |
Example
import com.aspose.threed.*;
// Create from components
FVector3 normal = new FVector3(0.0f, 1.0f, 0.0f);
// Convert from double-precision
Vector3 dir = new Vector3(3.0, 4.0, 0.0);
FVector3 fDir = new FVector3(dir);
// Normalize
FVector3 unit = fDir.normalize();
System.out.println(unit.x); // 0.6f
System.out.println(unit.y); // 0.8f