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, FVector4FVector2
2要素の単精度浮動小数点ベクトルで、 x と y コンポーネントです。.
class FVector2:
def __init__(self, x: float = 0.0, y: float = 0.0): ...Example
| Example | Example | Example | Example |
|---|---|---|---|
x | float | 読み取り/書き込み | 第1コンポーネント。. |
y | float | 読み取り/書き込み | 第2成分。. |
Example
| Example | Example | Example |
|---|---|---|
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.0FVector3
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
| Example | Example | Example | Example |
|---|---|---|---|
x | float | 読み取り/書き込み | 最初のコンポーネント。. |
y | float | 読み取り/書き込み | 第2コンポーネント。. |
z | float | 読み取り/書き込み | 第3コンポーネント。. |
インデックスアクセスをサポートします:: v[0], v[1], v[2].
静的ファクトリメソッド
| Example | Example | Example |
|---|---|---|
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) |
インスタンスメソッド
| Example | Example | Example |
|---|---|---|
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
| Example | Example | Example | Example |
|---|---|---|---|
x | float | 読み取り/書き込み | 最初のコンポーネント。. |
y | float | 読み取り/書き込み | 第2コンポーネント。. |
z | float | 読み取り/書き込み | 第3コンポーネント。. |
w | float | 読み取り/書き込み | 第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倍精度ベクトルとの関係
| 単精度 | 倍精度 | 典型的な使用 |
|---|---|---|
FVector2 | Vector2 | 頂点要素に格納されたUV座標 |
FVector3 | Vector3 | 法線と接線が頂点要素に格納されます |
FVector4 | Vector4 | Example VertexElementFVector.data エントリ; さらに制御点変換 |
頂点要素データを設定する際、precision class のいずれかを渡すことができます。. set_data() 変換します Vector2/Vector3 値を FVector4 自動的に。.