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

multiply

描述

multiply 方法用于将两个四元数相乘得到一个新的四元数。

语法

quaternion.multiply(otherQuaternion)

参数

  • otherQuaternion: {Quaternion} 另一个四元数,用于将当前四元数乘以。

返回值

返回一个新的 Quaternion 对象,表示两个四元数相乘的结果。

示例

const q1 = new Yuka.Quaternion().setFromEuler(0, 0, Math.PI / 2);
const q2 = new Yuka.Quaternion().setFromEuler(0, 0, Math.PI / 2);
const q3 = q1.multiply(q2);

console.log(q3); // Quaternion { x: 0, y: 0.7071067811865476, z: 0, w: 0.7071067811865476 }

以上示例展示了如何创建两个旋转四元数,并通过 multiply 方法将它们相乘。该方法将创建一个新的四元数,表示两个四元数的相乘结果并将其存储在 q3 变量中。

异常

如果 otherQuaternion 不是一个 Quaternion 对象,则会抛出一个 TypeError 类型异常。