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

介绍

getDegreeOfMembership() 是Yuka js库中的一个模糊逻辑函数,用于计算某个值在模糊变量的语义集合中的隶属度(Degree of Membership)程度。

语法

getDegreeOfMembership(value, range)

参数

  • value : 需要计算隶属度程度的值。
  • range : 模糊变量的语义集合,以数组形式提供。

返回值

getDegreeOfMembership()函数会返回一个0到1之间的数字,用来表示该值在模糊变量语义集合中的隶属度程度,1表示完全隶属于集合,0则完全不隶属于集合。

示例

const range = [
  { start: 0, end: 10 },
  { start: 5, end: 15 },
  { start: 10, end: 20 },
  { start: 15, end: 25 }
];

getDegreeOfMembership(5, range); // 0.5
getDegreeOfMembership(12, range); // 0.2
getDegreeOfMembership(18, range); // 0.8

说明

getDegreeOfMembership()函数计算隶属度程度的方法是将输入值与每个语义集合的边界比较,采用的是最小值原则(Minimum). 对于某一个区间[c1,c2],隶属度程度为:

degreeOfMembership(x) = min[(x-c1)/(c2-c1), (c2-x)/(c2-c1), 1]

其中,x 为输入值,在 [c1,c2] 区间内时度量值为1,x 在 [c1,c2] 区间之外时度量值为0。

引用