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, FVector4FVector3
متجه عائم ذو مكوّنين بدقة مفردة مع x و y المكوّنات.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Example
| Example | Example | Example | Example |
|---|---|---|---|
x | float | قراءة/كتابة | المكوّن الأول. |
y | float | قراءة/كتابة | المكوّن الثاني. |
Example
| Example | Example | Example |
|---|---|---|
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.0FVector3
متجه عائم بدقة مفردة مكوّن من ثلاثة مكونات 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
| Example | Example | Example | Example |
|---|---|---|---|
x | float | قراءة/كتابة | المكوّن الأول. |
y | float | قراءة/كتابة | المكوّن الثاني. |
z | float | قراءة/كتابة | المكوّن الثالث. |
يدعم الوصول عبر الفهرس: v[0], v[1], v[2].
دوال المصنع الثابتة
| Example | Example | Example |
|---|---|---|
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) |
طرق الكائن
| Example | Example | Example |
|---|---|---|
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
| Example | Example | Example | Example |
|---|---|---|---|
x | float | قراءة/كتابة | المكوّن الأول. |
y | float | قراءة/كتابة | المكوّن الثاني. |
z | float | قراءة/كتابة | المكوّن الثالث. |
w | float | قراءة/كتابة | المكوّن الرابع. |
يدعم الوصول عبر الفهرس: 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العلاقة مع المتجهات ذات الدقة المزدوجة
| دقة أحادية | دقة مزدوجة | الاستخدام النموذجي |
|---|---|---|
FVector2 | Vector2 | إحداثيات UV مخزنة في عناصر الرأس |
FVector3 | Vector3 | الـNormals والـtangents مخزنة في عناصر الـvertex |
FVector4 | Vector4 | Example VertexElementFVector.data الإدخالات؛ أيضًا تحويل نقطة التحكم |
عند ضبط بيانات عنصر الـvertex، يمكنك تمرير إما فئة الدقة. set_data() يحوِّل Vector2/Vector3 القيم إلى FVector4 تلقائيًا.