Vector2
Methods
Vector2 เป็นเวกเตอร์สองส่วนประกอบที่ใช้ความแม่นยำแบบ double-precision กับ x และ y ส่วนประกอบ. มันถูกใช้เป็นหลักเพื่อเก็บพิกัดเทกเจอร์ UV ใน VertexElementUV ชั้นและเป็นประเภทแทนเจนต์สำหรับ KeyFrame.next_in_tangent และ KeyFrame.out_tangent ในเส้นโค้งแอนิเมชัน.
Methods: aspose.threed.utilities
from aspose.threed.utilities import Vector2Methods
| Methods | Methods |
|---|---|
Vector2() | Methods (0.0, 0.0) |
Vector2(x, y) | สร้างจากสอง float ค่า |
Methods
| Methods | Methods | Methods |
|---|---|---|
x | float | ส่วนประกอบ X (U ในพิกัดเทกเจอร์) |
y | float | ส่วนประกอบ Y (V ในพิกัดเทกเจอร์) |
length | float | ความยาวยูคลิด (sqrt(x²+y²)), อ่านอย่างเดียว |
length2 | float | ความยาวกำลังสอง (x²+y²), อ่านอย่างเดียว |
Methods
| Methods | ประเภทการคืนค่า | Methods |
|---|---|---|
set(x, y) | None | ตั้งค่าทั้งสองส่วนประกอบในที่เดียว |
Vector2.parse(s) | Vector2 | คงที่. แยกวิเคราะห์ "x y" การแสดงผลเป็นสตริง |
การเข้าถึงโดยดัชนี
สามารถเข้าถึงส่วนประกอบโดยใช้ดัชนีจำนวนเต็ม: v[0] → x, v[1] → y.
Methods
from aspose.threed.utilities import Vector2
# Create UV coordinates
uv_bottom_left = Vector2(0.0, 0.0)
uv_bottom_right = Vector2(1.0, 0.0)
uv_top_right = Vector2(1.0, 1.0)
# Length
print(uv_bottom_right.length) # 1.0
# Modify in place
uv_bottom_left.set(0.1, 0.1)
# or via property
uv_bottom_left.x = 0.05
# Use in a VertexElementUV data array
from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.utilities import Vector4
from aspose.threed.entities import VertexElementType
scene = Scene()
mesh = Mesh()
# Use _control_points to mutate the backing list (control_points returns a copy)
mesh._control_points.append(Vector4(0, 0, 0, 1))
mesh._control_points.append(Vector4(1, 0, 0, 1))
mesh._control_points.append(Vector4(0.5, 1, 0, 1))
mesh.create_polygon(0, 1, 2)
uv_layer = mesh.create_element_uv(VertexElementType.UV)
uv_layer.data.append(Vector2(0.0, 0.0))
uv_layer.data.append(Vector2(1.0, 0.0))
uv_layer.data.append(Vector2(0.5, 1.0))