Class Vector3
Paket: @aspose/3d (v24.12.0)
Vector3 API genelinde kullanılan birincil matematik türüdür @aspose/3d konumlar, yönler, Euler açıları ve ölçek faktörleri için API. Bu, @aspose/3d/utilities alt-yol.
export class Vector3import { Vector3 } from '@aspose/3d/utilities';
// or via the main entry point when used with Transform/GlobalTransform
import { Scene } from '@aspose/3d';Enumerations
İki konum arasındaki orta noktayı hesaplayın ve bir yön vektörünü normallaştırın.
import { Vector3 } from '@aspose/3d/utilities';
const a = new Vector3(1, 0, 0);
const b = new Vector3(0, 0, 4);
// Midpoint: average the components manually
const mid = new Vector3(
(a.x + b.x) * 0.5,
(a.y + b.y) * 0.5,
(a.z + b.z) * 0.5
);
console.log(`Midpoint: ${mid}`);
// Midpoint: Vector3(0.5, 0, 2)
// Normalized direction from a to b
const dir = b.minus(a).normalize();
console.log(`Direction: ${dir}`);
// Direction: Vector3(-0.2425..., 0, 0.9701...)
Enumerations
| Enumerations | Enumerations |
|---|---|
new Vector3(x, y, z) | Üç sayısal bileşenden oluştur. |
new Vector3(v) | Üç bileşenin tamamını aynı skaler değerle doldur. |
Enumerations
| Enumerations | Enumerations | Enumerations |
|---|---|---|
x | number | X bileşeni. Okunabilir ve yazılabilir. |
y | number | Y bileşeni. Okunabilir ve yazılabilir. |
z | number | Z bileşeni. Okunabilir ve yazılabilir. |
length | number (yalnızca okunabilir) | Öklid uzunluğu: sqrt(x² + y² + z²). |
length2 | number (yalnızca okunabilir) | Kare uzunluk: x² + y² + z². Daha ucuz length yalnızca büyüklükleri karşılaştırırken. |
zero | Vector3 (yalnızca okunabilir) | Yeni birini döndürür Vector3(0, 0, 0). |
one | Vector3 (yalnızca okunabilir) | Yeni bir nesne döndürür Vector3(1, 1, 1). |
unitX | Vector3 (yalnızca okuma) | Yeni bir nesne döndürür Vector3(1, 0, 0). |
unitY | Vector3 (yalnızca okuma) | Yeni bir nesne döndürür Vector3(0, 1, 0). |
unitZ | Vector3 (yalnızca okuma) | Yeni bir nesne döndürür Vector3(0, 0, 1). |
Enumerations
set(x, y, z)
Vektörü yerinde değiştirir, üç bileşeni de ayarlar.
set(newX: number, newY: number, newZ: number): voiddot(rhs)
Bu vektör ile … arasındaki skaler nokta çarpımını döndürür rhs.
dot(rhs: Vector3): numberEnumerations
import { Vector3 } from '@aspose/3d/utilities';
const up = new Vector3(0, 1, 0);
const dir = new Vector3(0.5, 0.5, 0).normalize();
const alignment = up.dot(dir);
console.log(`Dot: ${alignment.toFixed(4)}`); // Dot: 0.7071
cross(rhs)
Yeni bir nesne döndürür Vector3 bu vektör ile … arasındaki çapraz çarpım olan rhs.
cross(rhs: Vector3): Vector3Enumerations
import { Vector3 } from '@aspose/3d/utilities';
const right = new Vector3(1, 0, 0);
const up = new Vector3(0, 1, 0);
const forward = right.cross(up);
console.log(`Forward: ${forward}`);
// Forward: Vector3(0, 0, -1)
normalize()
Yeni bir nesne döndürür Vector3 aynı yönde ancak birim uzunlukta. Döndürür (0, 0, 0) eğer bu vektörün uzunluğu sıfırsa.
normalize(): Vector3minus(v)
Yeni bir nesne döndürür Vector3 eşittir this - v.
minus(v: Vector3): Vector3times(scalar)
Yeni bir nesne döndürür Vector3 eşittir this * scalar.
times(scalar: number): Vector3angleBetween(dir, up?)
Bu vektör ile arasındaki açıyı radyan cinsinden döndürür dir. Eğer up verildiğinde, açı, ona dik düzlemde hesaplanır up (o düzlemde işaretli açı).
angleBetween(dir: Vector3, up?: Vector3): numbersin()
Yeni bir tane döndürür Vector3 ile Math.sin bileşen bazında uygulanır.
sin(): Vector3cos()
Yeni bir tane döndürür Vector3 ile Math.cos bileşen bazında uygulanır.
cos(): Vector3equals(other)
Enumerations true eğer üç bileşen de kesinlikle eşitse.
equals(other: Vector3): booleancompareTo(other)
Enumerations -1, 0, ya da 1 üzerinde leksikografik sıralama kullanarak (x, y, z).
compareTo(other: Vector3): numberstatic parse(input)
Üç sayıyı boşlukla ayrılmış bir dizeyi bir … içine ayrıştırır Vector3. Biçim geçersizse bir istisna fırlatır.
static parse(input: string): Vector3Enumerations
import { Vector3 } from '@aspose/3d/utilities';
const v = Vector3.parse('1.5 2.0 -3.0');
console.log(`${v}`); // Vector3(1.5, 2, -3)
toString()
Şu biçimde bir dize döndürür Vector3(x, y, z).
toString(): string