Vector4
Methods
Vector4 הוא וקטור בעל 4 רכיבים בדיוק כפול x, y, z, ו w רכיבים. זהו הסוג הראשי המשמש לנקודות בקרה ב Mesh.control_points (איפה w = 1.0 למיקומים קרטזיים) ולנתונים רגילים ב VertexElementNormal.
Methods: aspose.threed.utilities
from aspose.threed.utilities import Vector4Methods
| Methods | Methods |
|---|---|
Vector4() | Methods (0, 0, 0, 1) |
Vector4(x, y, z) | מבנים משלושה מרכיבים; w מוגדר כברירת מחדל 1.0 |
Vector4(x, y, z, w) | מבנים מארבעה מרכיבים מפורשים |
Vector4(vec3) | מבנים מ‑a Vector3; w מוגדר ל 1.0 |
Vector4(vec3, w) | מבנים מ‑ Vector3 פלוס מפורש w |
Methods
| Methods | Methods | Methods |
|---|---|---|
x | float | רכיב X |
y | float | רכיב Y |
z | float | רכיב Z |
w | float | רכיב W (משקל הומוגני; בדרך כלל 1.0 למיקומים) |
Methods
| Methods | סוג החזרה | Methods |
|---|---|---|
set(x, y, z, w=1.0) | None | מגדיר את כל ארבעת הרכיבים במקום |
גישה לפי אינדקס
ניתן לגשת לרכיבים באמצעות אינדקס שלם: v[0] → x, v[1] → y, v[2] → z, v[3] → w.
Methods
from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.utilities import Vector4
scene = Scene()
mesh = Mesh()
# Control points use Vector4 with w=1.0
# Use _control_points to mutate the backing list (control_points returns a copy)
mesh._control_points.append(Vector4(0.0, 0.0, 0.0, 1.0))
mesh._control_points.append(Vector4(1.0, 0.0, 0.0, 1.0))
mesh._control_points.append(Vector4(0.5, 1.0, 0.0, 1.0))
# Create a triangle polygon
mesh.create_polygon(0, 1, 2)
node = scene.root_node.create_child_node("triangle", mesh)
# Reading a control point
pt = mesh.control_points[0]
print(pt.x, pt.y, pt.z, pt.w) # 0.0 0.0 0.0 1.0
# Construct from Vector3
from aspose.threed.utilities import Vector3
v3 = Vector3(5.0, 3.0, 2.0)
v4 = Vector4(v3) # w defaults to 1.0
v4b = Vector4(v3, 0.0) # explicit w for direction (w=0)