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 Vector3
import { 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

EnumerationsEnumerations
new Vector3(x, y, z)Üç sayısal bileşenden oluştur.
new Vector3(v)Üç bileşenin tamamını aynı skaler değerle doldur.

Enumerations

EnumerationsEnumerationsEnumerations
xnumberX bileşeni. Okunabilir ve yazılabilir.
ynumberY bileşeni. Okunabilir ve yazılabilir.
znumberZ bileşeni. Okunabilir ve yazılabilir.
lengthnumber (yalnızca okunabilir)Öklid uzunluğu: sqrt(x² + y² + z²).
length2number (yalnızca okunabilir)Kare uzunluk: x² + y² + z². Daha ucuz length yalnızca büyüklükleri karşılaştırırken.
zeroVector3 (yalnızca okunabilir)Yeni birini döndürür Vector3(0, 0, 0).
oneVector3 (yalnızca okunabilir)Yeni bir nesne döndürür Vector3(1, 1, 1).
unitXVector3 (yalnızca okuma)Yeni bir nesne döndürür Vector3(1, 0, 0).
unitYVector3 (yalnızca okuma)Yeni bir nesne döndürür Vector3(0, 1, 0).
unitZVector3 (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): void

dot(rhs)

Bu vektör ile … arasındaki skaler nokta çarpımını döndürür rhs.

dot(rhs: Vector3): number

Enumerations

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): Vector3

Enumerations

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(): Vector3

minus(v)

Yeni bir nesne döndürür Vector3 eşittir this - v.

minus(v: Vector3): Vector3

times(scalar)

Yeni bir nesne döndürür Vector3 eşittir this * scalar.

times(scalar: number): Vector3

angleBetween(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): number

sin()

Yeni bir tane döndürür Vector3 ile Math.sin bileşen bazında uygulanır.

sin(): Vector3

cos()

Yeni bir tane döndürür Vector3 ile Math.cos bileşen bazında uygulanır.

cos(): Vector3

equals(other)

Enumerations true eğer üç bileşen de kesinlikle eşitse.

equals(other: Vector3): boolean

compareTo(other)

Enumerations -1, 0, ya da 1 üzerinde leksikografik sıralama kullanarak (x, y, z).

compareTo(other: Vector3): number

static 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): Vector3

Enumerations

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
 Türkçe