FVector2, FVector3, FVector4 — Aspose.3D Python API Reference
Paketti: aspose.threed.utilities (aspose-3d-foss 26.1.0)
Methods FVector tyypit ovat yksittäistarkkuuden (float32) vektoriluokkia, joita käytetään sisäisesti vertex-elementtien data-taulukoissa. Ne vaihtavat yksittäistarkkuuden muistitehokkuuden kaksinkertaisen tarkkuuden vastineeksi Vector2, Vector3, Vector4 luokkia, joita käytetään kohtausgraafin sijainteihin. Käytännössä luot näitä arvoja useimmiten täyttäessäsi VertexElementFVector.set_data().
from aspose.threed.utilities import FVector2, FVector3, FVector4FVector3
Kahden komponentin yksittäistarkkuuden liukulukuvektori, jossa on x ja y komponenttia.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Methods
| Methods | Methods | Methods | Methods |
|---|---|---|---|
x | float | luku/kirjoitus | Ensimmäinen komponentti. |
y | float | luku/kirjoitus | Toinen komponentti. |
Methods
| Methods | Methods | Methods |
|---|---|---|
length() | float | Vektorin euklidinen pituus: sqrt(x² + y²). |
normalize() | FVector2 | Palauta yksikköpituinen kopio. Palauttaa FVector2(0, 0) nollavektorille. |
dot(other) | float | Pistetulo other. |
FVector2.parse(s) | FVector2 | Jäsennä välilyönneillä erotettu merkkijono "x y" muuttujaan FVector2. |
Methods +, -, * (skaalaarinen), / (skaalaarinen), ja == operaattorit.
Methods
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
Kolmikomponenttinen yksittäistarkkuuden liukulukuvektori, jossa x, y, ja z komponenttia.
class FVector3:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...FVector3 myös hyväksyy Vector3, Vector4, tai FVector4 ensimmäisenä argumenttinaan muuntaakseen näistä tyypeistä.
Methods
| Methods | Methods | Methods | Methods |
|---|---|---|---|
x | float | luku/kirjoitus | Ensimmäinen komponentti. |
y | float | luku/kirjoitus | Toinen komponentti. |
z | float | luku/kirjoitus | Kolmas komponentti. |
Tukee indeksipääsyä: v[0], v[1], v[2].
Staattiset tehdasmenetelmät
| Methods | Methods | Methods |
|---|---|---|
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) |
Instanssimetodit
| Methods | Methods | Methods |
|---|---|---|
normalize() | FVector3 | Palauttaa yksikköpituuden kopion. Palauttaa nollavektorin nollapituuden syötteelle. |
Methods
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
Neljäkomponenttinen yksittäistarkkuuden liukulukuvektori, jossa x, y, z, ja w komponentit. Tämä on tallennustyyppi, jota käyttää VertexElementFVector.data.
class FVector4:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...FVector4 hyväksyy myös FVector3, Vector3, tai Vector4 sen ensimmäisenä argumenttina.
Methods
| Methods | Methods | Methods | Methods |
|---|---|---|---|
x | float | luku/kirjoitus | Ensimmäinen komponentti. |
y | float | luku/kirjoitus | Toinen komponentti. |
z | float | luku/kirjoitus | Kolmas komponentti. |
w | float | luku/kirjoitus | Neljäs komponentti. |
Tukee indeksipääsyä: v[0] kautta v[3].
Methods
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.0Suhde double‑tarkkuuden vektoreihin
| Yksittäistarkkuus | Kaksoistarkkuus | Tyypillinen käyttö |
|---|---|---|
FVector2 | Vector2 | UV-koordinaatit tallennettu vertex-elementteihin |
FVector3 | Vector3 | Normaalit, tangentit tallennettu vertex-elementteihin |
FVector4 | Vector4 | Methods VertexElementFVector.data merkinnät; myös ohjauspisteen muunnos |
Kun asetat vertex element -tietoa, voit antaa joko tarkkuusluokan. set_data() muuntaa Vector2/Vector3 arvot FVector4 automaattisesti.