Vector3 — Aspose.3D FOSS for Java

Example

Vector3 は、倍精度の3成分ベクトルです x, y,、および z 成分です。Aspose.3D全体で位置、方向、法線、スケール値に使用されます。すべての算術演算は新しい Vector3 インスタンス; 元のインスタンスは変更されません。.

import com.aspose.threed.*;

// Construct from components
Vector3 v = new Vector3(1.0, 2.0, 3.0);

// Copy constructor
Vector3 v2 = new Vector3(v);

// Default (zero vector)
Vector3 zero = new Vector3();

Example

ExampleExample
Vector3()ゼロベクトルを構築します (0, 0, 0)
Vector3(double x, double y, double z)3つの成分から構築します
Vector3(Vector3 other)コピーコンストラクタ

公開フィールド

Vector3 使用します パブリックフィールド コンポーネントへのアクセス用(getter/setter メソッドではなく):

ExampleExampleExampleExample
xdoublev.xX 成分
ydoublev.yY 成分
zdoublev.zZ 成分

計算プロパティ

ExampleExampleExampleExample
lengthdoublegetLength()ユークリッド長さ (sqrt(x^2+y^2+z^2)), 読み取り専用
length2doublegetLength2()二乗長さ、読み取り専用;以下よりコストが低い getLength() 比較だけが必要な場合

静的フィールド

ExampleExampleExample
ZEROVector3Vector3(0, 0, 0)
ONEVector3Vector3(1, 1, 1)
UNIT_XVector3Vector3(1, 0, 0)
UNIT_YVector3Vector3(0, 1, 0)
UNIT_ZVector3Vector3(0, 0, 1)

Example

Example戻り値の型Example
set(double x, double y, double z)void3 つの成分すべてをその場で設定する
dot(Vector3 rhs)double他のベクトルとのドット積 Vector3
cross(Vector3 rhs)Vector3外積 – 両オペランドに垂直なベクトルを返す
normalize()Vector3単位長さのコピーを返す;長さがゼロの場合はゼロベクトルを返す
angleBetween(Vector3 dir)doubleこのベクトルと…の間の角度(ラジアン) dir
angleBetween(Vector3 dir, Vector3 up)double…によって定義される平面上に射影された符号付き角度(ラジアン) up
sin()Vector3要素ごとの正弦
cos()Vector3要素ごとの余弦
compareTo(Vector3 other)int辞書順比較: -1、0、または1を返す
Vector3.parse(String s)Vector3静的。解析 "x y z" 文字列表現

Example

import com.aspose.threed.*;
import com.aspose.threed.Scene;

// Basic arithmetic
Vector3 a = new Vector3(1.0, 0.0, 0.0);
Vector3 b = new Vector3(0.0, 1.0, 0.0);

// Dot and cross products
double dot = a.dot(b);           // 0.0
Vector3 perp = a.cross(b);      // Vector3(0, 0, 1)

// Normalize
Vector3 direction = new Vector3(3.0, 4.0, 0.0);
Vector3 unit = direction.normalize();   // Vector3(0.6, 0.8, 0.0)
System.out.println(unit.getLength());    // 1.0

// Angle between vectors
double angle = a.angleBetween(b);
System.out.println(Math.toDegrees(angle));   // 90.0

// Use with a scene node transform
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("box");
node.getTransform().setTranslation(new Vector3(10.0, 0.0, 0.0));

参照

 日本語