Vector2
Methods
Vector2 є вектором з подвійною точністю, що має 2 компоненти, з x і y компонентами. 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))