Vector4
Methods
Vector4 是一个双精度四分量向量,具有 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) | 从一个 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)