AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

extractBasis

extractBasis 方法用于从一个 4x4 矩阵中提取其基向量。

语法

Matrix4.extractBasis(matrix);

参数

  • matrix:一个 4x4 的矩阵。

返回值

一个数组,包含三个向量,分别代表矩阵的右、上和前向量。

示例

const matrix = new Matrix4();
matrix.makeRotationX(Math.PI / 4);

const [rightVec, upVec, frontVec] = Matrix4.extractBasis(matrix);

说明

该方法将四维矩阵中的前三列向量标准化,然后将它们依次赋值给返回的向量数组中。

举个例子,假设我们有如下矩阵:

a b c d
e f g h
i j k l
m n o p

则提取的基向量为:

  • 右向量:(a, e, i)
  • 上向量:(b, f, j)
  • 前向量:(c, g, k)

版权说明

本方法是 Yuka 库的一部分,遵循 MIT 开源许可证。更多信息请参阅 https://github.com/mawa-repo/yuka 。