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

getDegreeOfMembership

功能说明

该函数用于计算当前值在Left Shoulder Fuzzy Set中的隶属度。

函数原型

getDegreeOfMembership(value, peak, left, right)

参数说明

  • value:(number) 当前需要计算隶属度的值。
  • peak:(number) Fuzzy Set的顶点。
  • left:(number) Fuzzy Set左侧的起始点。
  • right:(number) Fuzzy Set右侧的结束点。

返回值

  • 隶属度:0~1之间的实数,表示当前值在Fuzzy Set中的隶属程度。

算法实现

  1. 判断当前值是否小于等于左侧起始点,如果是,返回隶属度1,否则进入下一步操作。
  2. 如果当前值大于等于顶点,返回0。
  3. 计算当前值所在区间左侧点和顶点的距离d1 ,以及当前值所在区间右侧点和顶点的距离d2
  4. 根据当前值与Left Shoulder Fuzzy Set的三个关键点的位置,使用线性插值计算当前值的隶属度。 具体公式如下:

$$ degreeOfMembership= \left{ \begin{aligned} 1,\qquad\qquad\qquad\quad& value \le left \ 0,\qquad\qquad\qquad\quad& value \ge peak \ \frac{peak-value}{peak-left},\hspace{0.23cm}& left< value \le peak\ \frac{right-value}{right-peak},\hspace{0.23cm}& peak< value< right \end{aligned} \right. $$

示例

const peak = 50;
const left = 20;
const right = 80;
const lsf = new LeftShoulderFuzzySet(peak, left, right);
const value1 = 40;
console.log(lsf.getDegreeOfMembership(value1, peak, left, right)); // 0.6
const value2 = 10;
console.log(lsf.getDegreeOfMembership(value2, peak, left, right)); // 1