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

2要素の単精度浮動小数点ベクトルで、 xy コンポーネントです。.

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

Example

ExampleExampleExampleExample
xfloat読み取り/書き込み第1コンポーネント。.
yfloat読み取り/書き込み第2成分。.

Example

ExampleExampleExample
length()floatベクトルのユークリッド長さ:: sqrt(x² + y²).
normalize()FVector2単位長さのコピーを返す。Returns 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要素の単精度浮動小数点ベクトルで、 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読み取り/書き込み第2コンポーネント。.
zfloat読み取り/書き込み第3コンポーネント。.

インデックスアクセスをサポートします:: 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単位長さのコピーを返します。長さがゼロの入力に対してはゼロベクトルを返します。.

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 コンポーネントの単精度浮動小数点ベクトルで、 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 また、an を受け付けます FVector3, Vector3,、または Vector4 を最初の引数として。.

Example

ExampleExampleExampleExample
xfloat読み取り/書き込み最初のコンポーネント。.
yfloat読み取り/書き込み第2コンポーネント。.
zfloat読み取り/書き込み第3コンポーネント。.
wfloat読み取り/書き込み第4コンポーネント。.

インデックスアクセスをサポート: 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

倍精度ベクトルとの関係

単精度倍精度典型的な使用
FVector2Vector2頂点要素に格納されたUV座標
FVector3Vector3法線と接線が頂点要素に格納されます
FVector4Vector4Example VertexElementFVector.data エントリ; さらに制御点変換

頂点要素データを設定する際、precision class のいずれかを渡すことができます。. set_data() 変換します Vector2/Vector3 値を FVector4 自動的に。.


参照

 日本語