Vector4
Methods
Vector4 là một vector 4 thành phần độ chính xác kép với x, y, z, và w các thành phần. Đây là kiểu chính được sử dụng cho các điểm điều khiển trong Mesh.control_points (trong đó w = 1.0 cho vị trí Cartesian) và cho dữ liệu pháp tuyến trong VertexElementNormal.
Methods: aspose.threed.utilities
from aspose.threed.utilities import Vector4Methods
| Methods | Methods |
|---|---|
Vector4() | Methods (0, 0, 0, 1) |
Vector4(x, y, z) | Tạo dựng từ ba thành phần; w mặc định là 1.0 |
Vector4(x, y, z, w) | Tạo dựng từ bốn thành phần rõ ràng |
Vector4(vec3) | Tạo dựng từ một Vector3; w được đặt thành 1.0 |
Vector4(vec3, w) | Tạo dựng từ một Vector3 cộng với các thành phần rõ ràng w |
Methods
| Methods | Methods | Methods |
|---|---|---|
x | float | thành phần X |
y | float | thành phần Y |
z | float | thành phần Z |
w | float | thành phần W (trọng số đồng nhất; thường là 1.0 cho các vị trí) |
Methods
| Methods | Kiểu trả về | Methods |
|---|---|---|
set(x, y, z, w=1.0) | None | Thiết lập tất cả bốn thành phần tại chỗ |
Truy cập theo chỉ mục
Các thành phần có thể được truy cập bằng chỉ số nguyên: 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)