Vector3

Methods

Vector3 הוא וקטור בת שלושה רכיבים בדיוק כפול עם x, y, ו z רכיבים. הוא משמש בכל רחבי Aspose.3D למיקומים, כיוונים, נורמליות, ולערכי קנה מידה. כל הפעולות החשבוניות מחזירות Vector3 מופעים; המקור אינו משתנה.

from aspose.threed.utilities import Vector3

# Construct from components
v = Vector3(1.0, 2.0, 3.0)

# Copy constructor
v2 = Vector3(v)

# Default (zero vector)
zero = Vector3()

Methods

MethodsMethods
Vector3()בונה את וקטור האפס (0, 0, 0)
Vector3(x, y, z)בונה משלוש float רכיבים
Vector3(other)בנאי העתקה — מקבל אחר Vector3

Methods

כל הרכיבים הם תכונות קריאה וכתיבה; יש לגשת אליהם ללא סוגריים.

MethodsMethodsMethods
xfloatרכיב X
yfloatרכיב Y
zfloatרכיב Z
lengthfloatאורך אוקלידי (sqrt(x²+y²+z²)), קריאה בלבד
length2floatאורך מרובע (x²+y²+z²), קריאה בלבד; זול יותר מ length כאשר נדרשת רק השוואה
zeroVector3Methods Vector3(0, 0, 0)
oneVector3Methods Vector3(1, 1, 1)
unit_xVector3Methods Vector3(1, 0, 0)
unit_yVector3Methods Vector3(0, 1, 0)
unit_zVector3Methods Vector3(0, 0, 1)

Methods

Methodsסוג החזרהMethods
set(x, y, z)Noneמגדיר את כל שלושת הרכיבים במקום
dot(rhs)floatמכפלה פנימית עם אחר Vector3
cross(rhs)Vector3מכפלה וקטורית — מחזירה וקטור המאונך לשני האופרנדים
normalize()Vector3מחזיר עותק באורך יחידה; מחזיר וקטור אפס אם האורך הוא אפס
angle_between(dir)floatזווית ברדיאנים בין וקטור זה ל dir
angle_between(dir, up)floatזווית עם סימן ברדיאנים המוקרנת על המישור המוגדר על ידי up
sin()Vector3סינוס רכיב-רכיב
cos()Vector3קוסינוס רכיב-רכיב
compare_to(other)intהשוואה לקסיקוגרפית: מחזירה −1, 0, או 1
Vector3.parse(s)Vector3סטטי. מפענח "x y z" ייצוג מחרוזת

גישה לפי אינדקס

ניתן לגשת לרכיבים באמצעות אינדקס שלם: v[0] → x, v[1] → y, v[2] → z.

Methods

from aspose.threed.utilities import Vector3

# Basic arithmetic (standard Python operators are supported)
a = Vector3(1.0, 0.0, 0.0)
b = Vector3(0.0, 1.0, 0.0)

# Dot and cross products
dot = a.dot(b)           # 0.0
perp = a.cross(b)        # Vector3(0, 0, 1)

# Normalize
direction = Vector3(3.0, 4.0, 0.0)
unit = direction.normalize()   # Vector3(0.6, 0.8, 0.0)
print(unit.length)             # 1.0

# Angle between vectors
import math
angle = a.angle_between(b)
print(math.degrees(angle))    # 90.0

# Use with a scene node transform
from aspose.threed import Scene
scene = Scene()
node = scene.root_node.create_child_node("box")
node.transform.translation = Vector3(10.0, 0.0, 0.0)

ראה גם

 עברית