Vector2

Methods

Vector2 là một vector 2 thành phần có độ chính xác double với xy các thành phần. Nó chủ yếu được dùng để lưu trữ tọa độ texture UV trong VertexElementUV các lớp và như kiểu tiếp tuyến cho KeyFrame.next_in_tangentKeyFrame.out_tangent trong các đường cong hoạt hình.

Methods: aspose.threed.utilities

from aspose.threed.utilities import Vector2

Methods

MethodsMethods
Vector2()Methods (0.0, 0.0)
Vector2(x, y)Khởi tạo từ hai float giá trị

Methods

MethodsMethodsMethods
xfloatThành phần X (U trong tọa độ texture)
yfloatThành phần Y (V trong tọa độ texture)
lengthfloatĐộ dài Euclid (sqrt(x²+y²)), chỉ đọc
length2floatĐộ dài bình phương (x²+y²), chỉ đọc

Methods

MethodsKiểu trả vềMethods
set(x, y)NoneĐặt cả hai thành phần tại chỗ
Vector2.parse(s)Vector2Tĩnh. Phân tích "x y" biểu diễn chuỗi

Truy cập theo chỉ mục

Các thành phần có thể được truy cập bằng chỉ mục nguyên: 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))

Xem thêm

 Tiếng Việt