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

fromPoints

简介

fromPoints是Yuka js库中的一个方法,它用于计算一组点的最小外接球体。

语法

BoundingSphere.fromPoints( points, result );

参数

  • points:一个包含点的数组。
  • result:计算结果的BoundingSphere实例。

示例

const points = [
  new Vector3( 0, 0, 0 ),
  new Vector3( 0, 1, 0 ),
  new Vector3( 1, 0, 0 ),
  new Vector3( 1, 1, 0 ),
  new Vector3( 0.5, 0.5, 1 )
];

const boundingSphere = new BoundingSphere();
BoundingSphere.fromPoints( points, boundingSphere );

此示例将使用给定点的坐标计算最小外接球体,并将其存储在boundingSphere变量中。

注意事项

  • 如果result参数未提供,则将创建一个新的BoundingSphere实例并返回。
  • points参数必须包含至少一个点。 否则,该方法将不会运行并引发错误。
  • 此方法使用Ritter算法计算最小外接球体,具有较高的执行效率和良好的近似精度。