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

multiplyScalar

描述

multiplyScalar 方法将矩阵的每个元素乘以一个标量值。

用法

matrix.multiplyScalar(scalar);

参数

  • scalar (Number) - 用于乘以矩阵的标量值。

返回值

  • this (Matrix3) - 返回一个已经被当前矩阵乘以标量值的新矩阵。

示例

import { Matrix3 } from 'yuka';

const matrix = new Matrix3().set(
  1, 2, 3,
  4, 5, 6,
  7, 8, 9
);

const scalar = 2;

const result = matrix.multiplyScalar(scalar);

// result.elements 变为
// [
//   2, 4, 6,
//   8, 10, 12,
//   14, 16, 18
// ]

异常

  • TypeError - 如果 scalar 不是 Number 类型。

参考

  • Matrix3 - Yuka 中的矩阵类。

作者