FVector2 / FVector3 / FVector4

FVector2, FVector3, FVector4 — Aspose.3D Python API Reference

חבילה: aspose.threed.utilities (aspose-3d-foss 26.1.0)

Example FVector הסוגים הם single-precision (float32) מחלקות וקטור המשמשות פנימית על ידי מערכי נתוני רכיבי קודקוד. הן מחליפות את יעילות הזיכרון של single precision כנגד ה-double precision של ה- Vector2, Vector3, Vector4 מחלקות המשמשות למיקומי גרף סצנה. בפועל, ברוב המקרים תיצור ערכים אלה בעת מילוי VertexElementFVector.set_data().

from aspose.threed.utilities import FVector2, FVector3, FVector4

FVector3

וקטור float single-precision בעל שני רכיבים עם x ו y רכיבים.

class FVector2:
    def __init__(self, x: float = 0.0, y: float = 0.0): ...

Example

ExampleExampleExampleExample
xfloatקריאה/כתיבההרכיב הראשון.
yfloatקריאה/כתיבההרכיב השני.

Example

ExampleExampleExample
length()floatאורך אוקלידי של הווקטור: sqrt(x² + y²).
normalize()FVector2מחזיר עותק באורך יחידה. מחזיר FVector2(0, 0) לוקטור האפס.
dot(other)floatמכפלה סקלרית עם other.
FVector2.parse(s)FVector2פענח מחרוזת מופרדת ברווחים "x y" אל FVector2.

Example +, -, * (scalar), / (scalar), ו == אופרטורים.

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.0

FVector3

וקטור של שלושה רכיבים בפורמט נקודה צפה חד-דיוק עם x, y, ו z רכיבים.

class FVector3:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...

FVector3 גם מקבל Vector3, Vector4, או FVector4 כארגומנט הראשון שלו כדי להמיר מאותם סוגים.

Example

ExampleExampleExampleExample
xfloatקריאה/כתיבההרכיב הראשון.
yfloatקריאה/כתיבההמרכיב השני.
zfloatקריאה/כתיבההמרכיב השלישי.

תומך בגישה לפי אינדקס: v[0], v[1], v[2].

מתודות יצרן סטטיות

ExampleExampleExample
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)

מתודות של מופע

ExampleExampleExample
normalize()FVector3מחזיר עותק באורך יחידה. מחזיר את וקטור האפס עבור קלט באורך אפס.

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

וקטור צף חד-דיוק בעל ארבעה מרכיבים עם x, y, z, ו w מרכיבים. זהו סוג האחסון שבו משתמש VertexElementFVector.data.

class FVector4:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...

FVector4 גם מקבל FVector3, Vector3, או Vector4 כארגומנט הראשון שלו.

Example

ExampleExampleExampleExample
xfloatקריאה/כתיבההמרכיב הראשון.
yfloatקריאה/כתיבההמרכיב השני.
zfloatקריאה/כתיבההמרכיב השלישי.
wfloatקריאה/כתיבההמרכיב הרביעי.

תומך בגישה לפי אינדקס: v[0] דרך 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

קשר לוקטורים ברמת דיוק כפול

דיוק יחידדיוק כפולשימוש טיפוסי
FVector2Vector2קואורדינטות UV מאוחסנות ברכיבי קודקוד
FVector3Vector3נורמליות, טנגנטים מאוחסנים ברכיבי קודקוד
FVector4Vector4Example VertexElementFVector.data רשומות; גם המרת נקודות בקרה

כאשר מגדירים נתוני רכיב קודקוד, ניתן להעביר מחלקת דיוק. set_data() ממיר Vector2/Vector3 ערכים ל FVector4 אוטומטית.


ראה גם

 עברית