FVector2, FVector3, FVector4 — Aspose.3D Python API Reference
Paket: aspose.threed.utilities (aspose-3d-foss 26.1.0)
Properties FVector tipovi su jednostruke preciznosti (float32) vektorske klase koje se interno koriste u nizovima podataka elemenata vrha. One razmenjuju memorijsku efikasnost jednostruke preciznosti naspram dvostruke preciznosti Vector2, Vector3, Vector4 klase koje se koriste za pozicije u grafu scene. U praksi ćete najčešće kreirati ove vrednosti prilikom popunjavanja VertexElementFVector.set_data().
from aspose.threed.utilities import FVector2, FVector3, FVector4FVector2
Dvo-komponentni vektor jednostruke preciznosti tipa float sa x i y komponentama.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
x | float | čitanje/pisanje | Prva komponenta. |
y | float | čitanje/pisanje | Druga komponenta. |
Properties
| Properties | Properties | Properties |
|---|---|---|
length() | float | Euklidska dužina vektora: sqrt(x² + y²). |
normalize() | FVector2 | Vrati kopiju jedinične dužine. Vraća FVector2(0, 0) za nulti vektor. |
dot(other) | float | Skalarni proizvod sa other. |
FVector2.parse(s) | FVector2 | Parsiraj string odvojen razmacima "x y" u FVector2. |
Properties +, -, * (skalar), / (skalar), i == operatori.
Properties
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 od tri komponente, jednostrukog preciznog float, sa x, y, i z komponente.
class FVector3:
def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...FVector3 takođe prihvata Vector3, Vector4, ili FVector4 kao svoj prvi argument da konvertuje iz tih tipova.
Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
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 metode fabrike
| Properties | Properties | Properties |
|---|---|---|
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
| Properties | Properties | Properties |
|---|---|---|
normalize() | FVector3 | Vraća kopiju jedinične dužine. Vraća nulti vektor za ulaz nulte dužine. |
Properties
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 od četiri komponente, jednostruke preciznosti, tipa float, sa x, y, z, i w komponentama. Ovo je tip skladištenja 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đe prihvata FVector3, Vector3, ili Vector4 kao njegov prvi argument.
Properties
| Properties | Properties | Properties | Properties |
|---|---|---|---|
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] preko v[3].
Properties
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 | Tipična upotreba |
|---|---|---|
FVector2 | Vector2 | UV koordinate pohranjene u elemente vrha |
FVector3 | Vector3 | Normale, tangente pohranjene u elemente vrha |
FVector4 | Vector4 | Properties VertexElementFVector.data unosi; takođe konverzija kontrolnih tačaka |
Pri postavljanju podataka elementa vrha, možete proslediti ili klasu preciznosti. set_data() konvertuje Vector2/Vector3 vrednosti u FVector4 automatski.