FVector2, FVector3, FVector4 — Aspose.3D Python API Reference
Paket: aspose.threed.utilities (aspose-3d-foss 26.1.0)
Enumerations FVector tipovi su jednostrukog preciznosti (float32) vektorske klase koje se interno koriste u nizovima podataka vršnih elemenata. One razmjenjuju memorijsku učinkovitost jednostrukog preciznosti nasuprot dvostrukoj preciznosti Vector2, Vector3, Vector4 klase koje se koriste za položaje u grafu scene. U praksi ćete najčešće stvarati ove vrijednosti prilikom popunjavanja VertexElementFVector.set_data().
from aspose.threed.utilities import FVector2, FVector3, FVector4FVector3
Dvo-komponentni vektor jednostrukog preciznog floata s x i y komponente.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
x | float | čitanje/pisanje | Prva komponenta. |
y | float | čitanje/pisanje | Druga komponenta. |
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
length() | float | Euklidska duljina vektora: sqrt(x² + y²). |
normalize() | FVector2 | Vrati kopiju jedinične duljine. Vraća FVector2(0, 0) za nulti vektor. |
dot(other) | float | Skalarni produkt s other. |
FVector2.parse(s) | FVector2 | Parsiraj razmakom odvojeni string "x y" u FVector2. |
Enumerations +, -, * (skalar), / (skalar), i == operatori.
Enumerations
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
Vektor s tri komponente u jednostrukoj preciznosti (float) s x, y, i z komponentama.
class FVector3:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...FVector3 također prihvaća Vector3, Vector4, ili FVector4 kao prvi argument za pretvaranje iz tih tipova.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
x | float | čitanje/pisanje | Prva komponenta. |
y | float | čitanje/pisanje | Druga komponenta. |
z | float | čitanje/pisanje | Treća komponenta. |
Podržava pristup indeksu: v[0], v[1], v[2].
Statičke tvorničke metode
| Enumerations | Enumerations | Enumerations |
|---|---|---|
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) |
Metode instance
| Enumerations | Enumerations | Enumerations |
|---|---|---|
normalize() | FVector3 | Vrati kopiju jedinične duljine. Vraća vektor nule za ulaz nulte duljine. |
Enumerations
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
Vektor s četiri komponente u jednostrukoj preciznosti tipa float s x, y, z, i w komponentama. Ovo je tip pohrane koji koristi VertexElementFVector.data.
class FVector4:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...FVector4 također prihvaća FVector3, Vector3, ili Vector4 kao prvi argument.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
x | float | čitanje/pisanje | Prva komponenta. |
y | float | čitanje/pisanje | Druga komponenta. |
z | float | čitanje/pisanje | Treća komponenta. |
w | float | čitanje/pisanje | Četvrta komponenta. |
Podržava indeksni pristup: v[0] kroz v[3].
Enumerations
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.0Odnos prema vektorima dvostruke preciznosti
| Jednostruka preciznost | Dvostruka preciznost | Uobičajena upotreba |
|---|---|---|
FVector2 | Vector2 | UV koordinate pohranjene u elementima vrha |
FVector3 | Vector3 | Normale, tangente pohranjene u elementima vrha |
FVector4 | Vector4 | Enumerations VertexElementFVector.data unosi; također pretvorba kontrolne točke |
Pri postavljanju podataka elementa vrha, možete proslijediti bilo koju klasu preciznosti. set_data() pretvara Vector2/Vector3 vrijednosti u FVector4 automatski.