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库FuzzyAND(模糊与)的一个方法,用于计算一个给定模糊集中一个特定元素的隶属度。

参数

  • element:待计算隶属度的元素

返回值

Number类型,表示元素在模糊集中的隶属度。

示例

const set = new FuzzySet([1, 2, 3], [0.2, 0.5, 0.8]);
const degree = set.getDegreeOfMembership(2);
console.log(degree); // 输出 0.5

在以上示例中,我们创建了一个FuzzySet实例,并传入了两个数组参数。第一个数组包含元素[1, 2, 3],第二个数组表示它们在模糊集中的隶属度,[0.2, 0.5, 0.8] 表示元素1的隶属度为0.2,元素2的隶属度为0.5,元素3的隶属度为0.8。然后我们调用getDegreeOfMembership方法,并将要计算隶属度的元素2作为参数传入,最后输出的就是元素2在模糊集中的隶属度0.5。

异常

调用getDegreeOfMembership方法时,如果传入的参数不在模糊集中,将抛出一个异常。