FVector2 / FVector3 / FVector4

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

الحزمة: aspose.threed.utilities (aspose-3d-foss 26.1.0)

Example FVector الأنواع هي ذات دقة مفردة (float32) فئات المتجهات المستخدمة داخليًا بواسطة مصفوفات بيانات عناصر القمم. إنها توازن بين كفاءة الذاكرة للـ single precision مقابل الـ double precision لل Vector2, Vector3, Vector4 الفئات المستخدمة لمواقع رسم المشهد. عمليًا، ستقوم غالبًا بإنشاء هذه القيم عند تعبئة VertexElementFVector.set_data().

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

FVector3

متجه عائم ذو مكوّنين بدقة مفردة مع 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 +, -, * (عدد قياسي)،, / (عدد قياسي)، و == العوامل.

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الـNormals والـtangents مخزنة في عناصر الـvertex
FVector4Vector4Example VertexElementFVector.data الإدخالات؛ أيضًا تحويل نقطة التحكم

عند ضبط بيانات عنصر الـvertex، يمكنك تمرير إما فئة الدقة. set_data() يحوِّل Vector2/Vector3 القيم إلى FVector4 تلقائيًا.


انظر أيضًا

 العربية