Vector3
Methods
Vector3 은(는) 이중 정밀도 3요소 벡터이며 x, y, 및 z 구성 요소입니다. 이는 Aspose.3D 전반에 걸쳐 위치, 방향, 법선 및 스케일 값에 사용됩니다. 모든 산술 연산은 새로운 Vector3 인스턴스를 반환합니다; 원본은 변경되지 않습니다.
from aspose.threed.utilities import Vector3
# Construct from components
v = Vector3(1.0, 2.0, 3.0)
# Copy constructor
v2 = Vector3(v)
# Default (zero vector)
zero = Vector3()Methods
| Methods | Methods |
|---|---|
Vector3() | 영벡터를 생성합니다 (0, 0, 0) |
Vector3(x, y, z) | 세 개의 float 구성 요소 |
Vector3(other) | 복사 생성자 — 다른 Vector3 |
Methods
모든 구성 요소는 읽기 및 쓰기 가능한 속성이며, 괄호 없이 접근합니다.
| Methods | Methods | Methods |
|---|---|---|
x | float | X 구성 요소 |
y | float | Y 구성 요소 |
z | float | Z 구성 요소 |
length | float | 유클리드 길이 (sqrt(x²+y²+z²)), 읽기 전용 |
length2 | float | 제곱 길이 (x²+y²+z²), 읽기 전용; 보다 저렴함 length 비교만 필요할 때 |
zero | Vector3 | Methods Vector3(0, 0, 0) |
one | Vector3 | Methods Vector3(1, 1, 1) |
unit_x | Vector3 | Methods Vector3(1, 0, 0) |
unit_y | Vector3 | Methods Vector3(0, 1, 0) |
unit_z | Vector3 | Methods Vector3(0, 0, 1) |
Methods
| Methods | 반환 유형 | Methods |
|---|---|---|
set(x, y, z) | None | 세 구성 요소를 모두 제자리에서 설정합니다 |
dot(rhs) | float | 다른 벡터와의 내적 Vector3 |
cross(rhs) | Vector3 | 크로스 곱 — 두 피연산자에 모두 수직인 벡터를 반환합니다 |
normalize() | Vector3 | 단위 길이 복사본을 반환합니다; 길이가 0이면 영벡터를 반환합니다 |
angle_between(dir) | float | 이 벡터와 사이의 라디안 각도 dir |
angle_between(dir, up) | float | 정의된 평면에 투영된 라디안 단위의 부호 각도 up |
sin() | Vector3 | 요소별 사인 |
cos() | Vector3 | 요소별 코사인 |
compare_to(other) | int | 사전식 비교: −1, 0, 또는 1을 반환합니다 |
Vector3.parse(s) | Vector3 | 정적. 구문 분석합니다 "x y z" 문자열 표현 |
인덱스 접근
구성 요소는 정수 인덱스로 접근할 수 있습니다: v[0] → x, v[1] → y, v[2] → z.
Methods
from aspose.threed.utilities import Vector3
# Basic arithmetic (standard Python operators are supported)
a = Vector3(1.0, 0.0, 0.0)
b = Vector3(0.0, 1.0, 0.0)
# Dot and cross products
dot = a.dot(b) # 0.0
perp = a.cross(b) # Vector3(0, 0, 1)
# Normalize
direction = Vector3(3.0, 4.0, 0.0)
unit = direction.normalize() # Vector3(0.6, 0.8, 0.0)
print(unit.length) # 1.0
# Angle between vectors
import math
angle = a.angle_between(b)
print(math.degrees(angle)) # 90.0
# Use with a scene node transform
from aspose.threed import Scene
scene = Scene()
node = scene.root_node.create_child_node("box")
node.transform.translation = Vector3(10.0, 0.0, 0.0)