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

computeUniqueVertices

功能描述

该函数用于在计算凸包时,从顶点列表中提取独特的顶点。

语法

computeUniqueVertices(vertices)

参数说明

vertices: {Array} 包含顶点坐标的数组。

返回值

函数将返回一个独特顶点数组,其中不会包含重复的顶点。

实现原理

本函数通过循环遍历所有顶点,对每个顶点进行一次比较,将不同的顶点收集到一个新的数组中。

实例

const vertices = [
  [0, 0],
  [0, 1],
  [1, 1],
  [1, 0]
];

const uniqueVertices = computeUniqueVertices(vertices);
console.log(uniqueVertices); 
// [[0, 0], [0, 1], [1, 1], [1, 0]]

注意事项

请勿直接将该函数用于任何生产环境中。本函数为ConvexHull算法的一个辅助函数,只能在特定情况下使用。如果需要在生产环境中使用该函数,请先进行相关测试和优化。