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

midpoint

简介

midpoint 方法是 Yuka js 库中 LeftShoulderFuzzySet 类的一个公共方法,它用于计算左肩模糊集的中点。模糊集合是指一个变量在某个范围内可能存在多个值,且每个值对应的概率不是确定的,而是模糊的。左肩模糊集的特点是左侧高峰,右侧平缓,可以用于实现 “较低” 这个模糊性概念。

语法

LeftShoulderFuzzySet.midpoint()

参数

此方法不接受任何参数。

返回值

midpoint 方法返回一个 number 类型,表示左肩模糊集的中点。

示例

const set = new LeftShoulderFuzzySet(0, 10, 5);
const midpoint = set.midpoint();
console.log(midpoint); // 输出 3.33

实现原理

左肩模糊集的中点是指模糊组的平均值,它的计算方式为:

$midpoint = left + (height / slope)$

其中,left 表示左端点,height 表示高峰值,slope 表示斜率。

LeftShoulderFuzzySet 中,这三个参数分别对应构造函数中的 leftpeakPointright

具体实现可以参考以下代码:

  midpoint() {
    const { left, peakPoint ,slope } = this;
    return left + (peakPoint - left) * (0.5 / slope);
  }

参考链接