FVector2 / FVector3 / FVector4

FVector2, FVector3, FVector4 — Aspose.3D Python API Reference

패키지: aspose.threed.utilities (aspose-3d-foss 26.1.0)

Example FVector 형식은 단정밀도 (float32) 벡터 클래스는 정점 요소 데이터 배열에서 내부적으로 사용됩니다. 이들은 단정밀도의 메모리 효율성을 이중 정밀도의 Vector2, Vector3, Vector4 클래스는 씬 그래프 위치에 사용됩니다. 실제로는 값을 채울 때 가장 자주 이러한 값을 생성하게 됩니다. VertexElementFVector.set_data().

from aspose.threed.utilities import FVector2, FVector3, FVector4

FVector2

두 구성 요소를 가진 단정밀도 부동소수점 벡터 with xy 구성 요소들.

class FVector2:
    def __init__(self, x: float = 0.0, y: float = 0.0): ...

Example

ExampleExampleExampleExample
xfloat읽기/쓰기첫 번째 구성 요소.
yfloat읽기/쓰기두 번째 성분.

Example

ExampleExampleExample
length()float벡터의 유클리드 길이: sqrt(x² + y²).
normalize()FVector2단위 길이 복사본을 반환합니다. 반환값은 FVector2(0, 0) 영벡터에 대해.
dot(other)float다음과의 내적 other.
FVector2.parse(s)FVector2공백으로 구분된 문자열을 구문 분석합니다 "x y" 다음으로 변환합니다: FVector2.

Example +, -, * (스칼라), / (스칼라), 및 == 연산자.

Example

from aspose.threed.utilities import FVector2

uv = FVector2(0.5, 0.25)
print(uv.x, uv.y)           # 0.5 0.25
print(uv.length())           # ~0.559
unit = uv.normalize()
print(round(unit.length(), 6))  # 1.0

a = FVector2(1.0, 0.0)
b = FVector2(0.0, 1.0)
print(a.dot(b))              # 0.0

FVector3

3개의 구성 요소를 가진 single-precision float vector x, y, 및 z 구성 요소들.

class FVector3:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0): ...

FVector3 또한 받습니다 Vector3, Vector4, 또는 FVector4 그러한 유형들로부터 변환하기 위해 첫 번째 인수로 사용합니다.

Example

ExampleExampleExampleExample
xfloat읽기/쓰기첫 번째 구성 요소.
yfloat읽기/쓰기두 번째 구성 요소.
zfloat읽기/쓰기세 번째 구성 요소.

인덱스 접근을 지원합니다: v[0], v[1], v[2].

정적 팩토리 메서드

ExampleExampleExample
FVector3.zero()FVector3(0, 0, 0)
FVector3.one()FVector3(1, 1, 1)
FVector3.unit_x()FVector3(1, 0, 0)
FVector3.unit_y()FVector3(0, 1, 0)
FVector3.unit_z()FVector3(0, 0, 1)

인스턴스 메서드

ExampleExampleExample
normalize()FVector3단위 길이 복사본을 반환합니다. 길이가 0인 입력에 대해서는 영벡터를 반환합니다.

Example

from aspose.threed.utilities import FVector3

n = FVector3(0.0, 1.0, 0.0)
print(n.normalize())         # FVector3(0.0, 1.0, 0.0)

up = FVector3.unit_y()
print(up.x, up.y, up.z)     # 0.0 1.0 0.0

# Convert from Vector3
from aspose.threed.utilities import Vector3
v = Vector3(1.0, 2.0, 3.0)
fv = FVector3(v)
print(fv)                    # FVector3(1.0, 2.0, 3.0)

FVector4

4개의 구성 요소를 가진 single-precision float vector x, y, z, 그리고 w 구성 요소. 이는 ~에 사용되는 저장 유형입니다 VertexElementFVector.data.

class FVector4:
    def __init__(self, x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 0.0): ...

FVector4 또한 ~를 허용합니다 FVector3, Vector3, 또는 Vector4 첫 번째 인수로서.

Example

ExampleExampleExampleExample
xfloat읽기/쓰기첫 번째 구성 요소.
yfloat읽기/쓰기두 번째 구성 요소.
zfloat읽기/쓰기세 번째 구성 요소.
wfloat읽기/쓰기네 번째 구성 요소.

인덱스 접근을 지원합니다: v[0] 통해 v[3].

Example

from aspose.threed.utilities import FVector4, FVector3

# Direct construction
normal = FVector4(0.0, 0.0, 1.0, 0.0)
print(normal.z)              # 1.0

# From FVector3
fv3 = FVector3(0.0, 1.0, 0.0)
fv4 = FVector4(fv3, 0.0)
print(fv4)                   # FVector4(0.0, 1.0, 0.0, 0.0)

# Index access
print(fv4[1])                # 1.0
fv4[3] = 1.0
print(fv4.w)                 # 1.0

double-precision 벡터와의 관계

단정밀도배정밀도일반적인 사용
FVector2Vector2UV 좌표가 정점 요소에 저장됨
FVector3Vector3법선 및 탄젠트가 정점 요소에 저장됨
FVector4Vector4Example VertexElementFVector.data 항목; 또한 제어점 변환

버텍스 요소 데이터를 설정할 때, precision class를 전달할 수 있습니다. set_data() 변환합니다 Vector2/Vector3 값을 FVector4 자동으로.


또 보기

 한국어