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) | 3つから構築します 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 | すべての3つの成分をインプレースで設定 |
dot(rhs) | float | 他のベクトルとのドット積 Vector3 |
cross(rhs) | Vector3 | クロス積 — 両オペランドに垂直なベクトルを返す |
normalize() | Vector3 | 単位長さのコピーを返す; 長さがゼロの場合はゼロベクトルを返す |
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)