Vector4

Methods

Vector4 เป็นเวกเตอร์ 4 ส่วนประกอบแบบ double-precision ที่มี x, y, z, และ w ส่วนประกอบ. มันเป็นประเภทหลักที่ใช้สำหรับจุดควบคุมใน Mesh.control_points (ที่ w = 1.0 สำหรับตำแหน่งคาร์ทีเซียน) และสำหรับข้อมูลปกติใน VertexElementNormal.

Methods: aspose.threed.utilities

from aspose.threed.utilities import Vector4

Methods

MethodsMethods
Vector4()Methods (0, 0, 0, 1)
Vector4(x, y, z)สร้างจากสามส่วนประกอบ; w ค่าเริ่มต้นเป็น 1.0
Vector4(x, y, z, w)สร้างจากสี่ส่วนประกอบที่ระบุอย่างชัดเจน
Vector4(vec3)สร้างจาก Vector3; w ตั้งค่าเป็น 1.0
Vector4(vec3, w)สร้างจาก Vector3 บวกกับที่ระบุอย่างชัดเจน w

Methods

MethodsMethodsMethods
xfloatส่วนประกอบ X
yfloatส่วนประกอบ Y
zfloatส่วนประกอบ Z
wfloatส่วนประกอบ 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)

ดูเพิ่มเติม

 ภาษาไทย