FVector2, FVector3, FVector4 — Aspose.3D Python API Reference
Paket: aspose.threed.utilities (aspose-3d-foss 26.1.0)
Example FVector türler tek duyarlıklı (float32) vektör sınıfları, köşe öğesi veri dizileri tarafından dahili olarak kullanılır. Tek duyarlılığın bellek verimliliği, sahne grafiği konumları için kullanılan çift duyarlılıkla takas edilir. Vector2, Vector3, Vector4 sahne grafiği konumları için kullanılan sınıflar. Pratikte, bu değerleri genellikle doldururken oluşturursunuz VertexElementFVector.set_data().
from aspose.threed.utilities import FVector2, FVector3, FVector4FVector2
İki bileşenli tek duyarlıklı float vektör, şu ile: x ve y bileşenler.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Example
| Example | Example | Example | Example |
|---|---|---|---|
x | float | okuma/yazma | İlk bileşen. |
y | float | okuma/yazma | İkinci bileşen. |
Example
| Example | Example | Example |
|---|---|---|
length() | float | Vektörün Öklid uzunluğu: sqrt(x² + y²). |
normalize() | FVector2 | Birim uzunlukta bir kopya döndürür. Döndürür FVector2(0, 0) sıfır vektör için. |
dot(other) | float | Nokta çarpımı ile other. |
FVector2.parse(s) | FVector2 | Boşlukla ayrılmış bir dizeyi ayrıştır "x y" birine FVector2. |
Example +, -, * (scalar), / (scalar), ve == operatörler.
Example
from aspose.threed.utilities import FVector2
uv = FVector2(0.5, 0.25)
print(uv.x, uv.y) # 0.5 0.25
print(uv.length()) # ~0.559
unit = uv.normalize()
print(round(unit.length(), 6)) # 1.0
a = FVector2(1.0, 0.0)
b = FVector2(0.0, 1.0)
print(a.dot(b)) # 0.0FVector3
Üç bileşenli tek duyarlıklı kayan nokta vektörü, şu özellikte: x, y, ve z bileşenler.
class FVector3:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...FVector3 aynı zamanda bir Vector3, Vector4, ya da FVector4 ilk argüman olarak bu türlerden dönüştürmek için.
Example
| Example | Example | Example | Example |
|---|---|---|---|
x | float | okuma/yazma | İlk bileşen. |
y | float | okuma/yazma | İkinci bileşen. |
z | float | okuma/yazma | Üçüncü bileşen. |
Dizin erişimini destekler: v[0], v[1], v[2].
Statik fabrika yöntemleri
| Example | Example | Example |
|---|---|---|
FVector3.zero() | FVector3 | (0, 0, 0) |
FVector3.one() | FVector3 | (1, 1, 1) |
FVector3.unit_x() | FVector3 | (1, 0, 0) |
FVector3.unit_y() | FVector3 | (0, 1, 0) |
FVector3.unit_z() | FVector3 | (0, 0, 1) |
Nesne yöntemleri
| Example | Example | Example |
|---|---|---|
normalize() | FVector3 | Birim uzunlukta bir kopya döndürür. Sıfır uzunlukta giriş için sıfır vektör döndürür. |
Example
from aspose.threed.utilities import FVector3
n = FVector3(0.0, 1.0, 0.0)
print(n.normalize()) # FVector3(0.0, 1.0, 0.0)
up = FVector3.unit_y()
print(up.x, up.y, up.z) # 0.0 1.0 0.0
# Convert from Vector3
from aspose.threed.utilities import Vector3
v = Vector3(1.0, 2.0, 3.0)
fv = FVector3(v)
print(fv) # FVector3(1.0, 2.0, 3.0)FVector4
Dört bileşenli tek duyarlıklı kayan nokta vektörü, şu özellikte: x, y, z, ve w bileşenler. Bu, tarafından kullanılan depolama türüdür VertexElementFVector.data.
class FVector4:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...FVector4 ayrıca bir FVector3, Vector3, veya Vector4 ilk argümanı olarak.
Example
| Example | Example | Example | Example |
|---|---|---|---|
x | float | okuma/yazma | İlk bileşen. |
y | float | okuma/yazma | İkinci bileşen. |
z | float | okuma/yazma | Üçüncü bileşen. |
w | float | okuma/yazma | Dördüncü bileşen. |
İndeks erişimini destekler: v[0] aracılığıyla v[3].
Example
from aspose.threed.utilities import FVector4, FVector3
# Direct construction
normal = FVector4(0.0, 0.0, 1.0, 0.0)
print(normal.z) # 1.0
# From FVector3
fv3 = FVector3(0.0, 1.0, 0.0)
fv4 = FVector4(fv3, 0.0)
print(fv4) # FVector4(0.0, 1.0, 0.0, 0.0)
# Index access
print(fv4[1]) # 1.0
fv4[3] = 1.0
print(fv4.w) # 1.0Çift duyarlıklı vektörlerle ilişkisi
| Tek duyarlıklı | Çift duyarlıklı | Tipik kullanım |
|---|---|---|
FVector2 | Vector2 | UV koordinatları köşe öğelerinde depolanır |
FVector3 | Vector3 | Normal vektörler ve teğetler köşe öğelerinde depolanır |
FVector4 | Vector4 | Example VertexElementFVector.data girdiler; ayrıca kontrol noktası dönüşümü |
Vertex eleman verilerini ayarlarken, kesinlik sınıfından birini geçebilirsiniz. set_data() dönüştürür Vector2/Vector3 değerleri FVector4 otomatik olarak.