Vector2
Methods
Vector2 یک بردار دو مؤلفهای با دقت دوگانه است 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))