Class Vector3
패키지: @aspose/3d (v24.12.0)
Vector3 전체 API에서 사용되는 기본 수학 타입입니다. @aspose/3d 위치, 방향, 오일러 각 및 스케일 팩터를 위한 API입니다. 이 타입은 다음에서 내보내집니다 @aspose/3d/utilities 서브 경로.
export class Vector3import { Vector3 } from '@aspose/3d/utilities';
// or via the main entry point when used with Transform/GlobalTransform
import { Scene } from '@aspose/3d';ImageRenderOptions
두 위치 사이의 중점을 계산하고 방향 벡터를 정규화합니다.
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...)
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions |
|---|---|
new Vector3(x, y, z) | 세 개의 숫자 구성 요소로부터 생성합니다. |
new Vector3(v) | 세 구성 요소 모두를 동일한 스칼라 값으로 채웁니다. |
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
x | number | X 구성 요소. 읽기 및 쓰기 가능. |
y | number | Y 구성 요소. 읽기 및 쓰기 가능. |
z | number | Z 구성 요소. 읽기 및 쓰기 가능. |
length | number (읽기 전용) | 유클리드 길이: sqrt(x² + y² + z²). |
length2 | number (읽기 전용) | 제곱 길이: x² + y² + z². 더 저렴함 length 오직 크기만 비교할 때. |
zero | Vector3 (읽기 전용) | 새로운 것을 반환합니다 Vector3(0, 0, 0). |
one | Vector3 (읽기 전용) | 새로운 객체를 반환합니다 Vector3(1, 1, 1). |
unitX | Vector3 (읽기 전용) | 새로운 객체를 반환합니다 Vector3(1, 0, 0). |
unitY | Vector3 (읽기 전용) | 새로운 객체를 반환합니다 Vector3(0, 1, 0). |
unitZ | Vector3 (읽기 전용) | 새로운 객체를 반환합니다 Vector3(0, 0, 1). |
ImageRenderOptions
set(x, y, z)
벡터를 제자리에서 변형하여 세 구성 요소를 모두 설정합니다.
set(newX: number, newY: number, newZ: number): voiddot(rhs)
이 벡터와의 스칼라 내적을 반환합니다 rhs.
dot(rhs: Vector3): numberImageRenderOptions
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)
새로운 객체를 반환합니다 Vector3 이 벡터와 …의 외적인 rhs.
cross(rhs: Vector3): Vector3ImageRenderOptions
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()
새로운 객체를 반환합니다 Vector3 같은 방향이지만 단위 길이를 갖는. 반환합니다 (0, 0, 0) 이 벡터의 길이가 0인 경우.
normalize(): Vector3minus(v)
새로운 객체를 반환합니다 Vector3 와 동일한 this - v.
minus(v: Vector3): Vector3times(scalar)
새로운 객체를 반환합니다 Vector3 와 같다 this * scalar.
times(scalar: number): Vector3angleBetween(dir, up?)
이 벡터와 사이의 각도를 라디안으로 반환합니다 dir. 만약 up 가 제공되면, 각도는 그에 수직인 평면에서 계산됩니다 up (그 평면에서의 부호가 있는 각도).
angleBetween(dir: Vector3, up?: Vector3): numbersin()
새로운 것을 반환합니다 Vector3 와 Math.sin 각 구성 요소에 적용됩니다.
sin(): Vector3cos()
새로운 것을 반환합니다 Vector3 와 Math.cos 각 구성 요소에 적용됩니다.
cos(): Vector3equals(other)
ImageRenderOptions true 세 구성 요소가 모두 정확히 동일한 경우.
equals(other: Vector3): booleancompareTo(other)
ImageRenderOptions -1, 0, 또는 1 에 대한 사전식 순서를 사용하여 (x, y, z).
compareTo(other: Vector3): numberstatic parse(input)
공백으로 구분된 세 숫자 문자열을 … 로 구문 분석합니다 Vector3. 형식이 올바르지 않으면 예외를 발생시킵니다.
static parse(input: string): Vector3ImageRenderOptions
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()
다음 형식의 문자열을 반환합니다 Vector3(x, y, z).
toString(): string