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

squaredLength

简介

squaredLength是Yuka js库中的一个函数,它用来计算半边数据结构中的线段的长度的平方。

参数

该函数参数如下:

  • startVertex:表示线段起点的顶点。
  • endVertex:表示线段终点的顶点。

返回值

该函数返回线段长度的平方值。

例子

下面是一个例子,展示如何使用squaredLength函数:

const halfEdge = new HalfEdge();
const vertex1 = new Vertex(0, 0, 0);
const vertex2 = new Vertex(1, 1, 1);
const edge = halfEdge.addEdge(vertex1, vertex2);
const lengthSquared = HalfEdge.squaredLength(edge.startVertex, edge.endVertex);
console.log(lengthSquared); // 输出:3

总结

squaredLength函数可以很方便地计算半边数据结构中的线段的长度的平方。使用这个函数,可以简化相关的计算工作,提高代码编写效率。