@@ -68,6 +68,119 @@ public struct SealedForceDescriptor<NodeID: Hashable>: _ForceDescriptor {
68
68
}
69
69
}
70
70
71
+
72
+ @inlinable
73
+ @discardableResult
74
+ public static func center( x: Double = 0.0 , y: Double = 0.0 , strength: Double = 0.5 ) -> Self {
75
+ SealedForceDescriptor ( [ . center( CenterForce ( x: x, y: y, strength: strength) ) ] )
76
+ }
77
+
78
+ @inlinable
79
+ @discardableResult
80
+ public static func manyBody( strength: Double = - 30.0 , mass: ManyBodyForce < NodeID > . NodeMass = . constant( 1.0 ) , theta: Double = 0.9 ) -> Self {
81
+ SealedForceDescriptor ( [ . manyBody( ManyBodyForce ( strength: strength, mass: mass, theta: theta) ) ] )
82
+ }
83
+
84
+ @inlinable
85
+ @discardableResult
86
+ public static func link(
87
+ originalLength: LinkForce < NodeID > . LinkLength = . constant( 30.0 ) ,
88
+ stiffness: LinkForce < NodeID > . Stiffness = . weightedByDegree { _, _ in 1.0 } ,
89
+ iterationsPerTick: UInt = 1
90
+ ) -> Self {
91
+ SealedForceDescriptor ( [ . link( LinkForce ( originalLength: originalLength, stiffness: stiffness, iterationsPerTick: iterationsPerTick) ) ] )
92
+ }
93
+
94
+ @inlinable
95
+ @discardableResult
96
+ public static func collide(
97
+ strength: Double = 0.5 ,
98
+ radius: CollideForce < NodeID > . CollideRadius = . constant( 3.0 ) ,
99
+ iterationsPerTick: UInt = 1
100
+ ) -> Self {
101
+ SealedForceDescriptor ( [ . collide( CollideForce ( strength: strength, radius: radius, iterationsPerTick: iterationsPerTick) ) ] )
102
+ }
103
+
104
+ @inlinable
105
+ @discardableResult
106
+ public static func position(
107
+ direction: Kinetics2D . DirectionOfPositionForce ,
108
+ targetOnDirection: PositionForce < NodeID > . TargetOnDirection ,
109
+ strength: PositionForce < NodeID > . PositionStrength = . constant( 1.0 )
110
+ ) -> Self {
111
+ SealedForceDescriptor ( [ . position( PositionForce ( direction: direction, targetOnDirection: targetOnDirection, strength: strength) ) ] )
112
+ }
113
+
114
+ @inlinable
115
+ @discardableResult
116
+ public static func radial(
117
+ center: SIMD2 < Double > = . zero,
118
+ strength: RadialForce < NodeID > . RadialStrength = . constant( 1.0 ) ,
119
+ radius: RadialForce < NodeID > . Radius = . constant( 3.0 )
120
+ ) -> Self {
121
+ SealedForceDescriptor ( [ . radial( RadialForce ( center: center, strength: strength, radius: radius) ) ] )
122
+ }
123
+
124
+
125
+ @inlinable
126
+ @discardableResult
127
+ public consuming func center( x: Double = 0.0 , y: Double = 0.0 , strength: Double = 0.5 ) -> Self {
128
+ storage. append ( . center( CenterForce ( x: x, y: y, strength: strength) ) )
129
+ return self
130
+ }
131
+
132
+ @inlinable
133
+ @discardableResult
134
+ public consuming func manyBody( strength: Double = - 30.0 , mass: ManyBodyForce < NodeID > . NodeMass = . constant( 1.0 ) , theta: Double = 0.9 ) -> Self {
135
+ storage. append ( . manyBody( ManyBodyForce ( strength: strength, mass: mass, theta: theta) ) )
136
+ return self
137
+ }
138
+
139
+ @inlinable
140
+ @discardableResult
141
+ public consuming func link(
142
+ originalLength: LinkForce < NodeID > . LinkLength = . constant( 30.0 ) ,
143
+ stiffness: LinkForce < NodeID > . Stiffness = . weightedByDegree { _, _ in 1.0 } ,
144
+ iterationsPerTick: UInt = 1
145
+ ) -> Self {
146
+ storage. append ( . link( LinkForce ( originalLength: originalLength, stiffness: stiffness, iterationsPerTick: iterationsPerTick) ) )
147
+ return self
148
+ }
149
+
150
+ @inlinable
151
+ @discardableResult
152
+ public consuming func collide(
153
+ strength: Double = 0.5 ,
154
+ radius: CollideForce < NodeID > . CollideRadius = . constant( 3.0 ) ,
155
+ iterationsPerTick: UInt = 1
156
+ ) -> Self {
157
+ storage. append ( . collide( CollideForce ( strength: strength, radius: radius, iterationsPerTick: iterationsPerTick) ) )
158
+ return self
159
+ }
160
+
161
+ @inlinable
162
+ @discardableResult
163
+ public consuming func position(
164
+ direction: Kinetics2D . DirectionOfPositionForce ,
165
+ targetOnDirection: PositionForce < NodeID > . TargetOnDirection ,
166
+ strength: PositionForce < NodeID > . PositionStrength = . constant( 1.0 )
167
+ ) -> Self {
168
+ storage. append ( . position( PositionForce ( direction: direction, targetOnDirection: targetOnDirection, strength: strength) ) )
169
+ return self
170
+ }
171
+
172
+ @inlinable
173
+ @discardableResult
174
+ public consuming func radial(
175
+ center: SIMD2 < Double > = . zero,
176
+ strength: RadialForce < NodeID > . RadialStrength = . constant( 1.0 ) ,
177
+ radius: RadialForce < NodeID > . Radius = . constant( 3.0 )
178
+ ) -> Self {
179
+ storage. append ( . radial( RadialForce ( center: center, strength: strength, radius: radius) ) )
180
+ return self
181
+ }
182
+
183
+
71
184
@inlinable
72
185
init ( _ storage: [ Entry ] = [ ] ) {
73
186
self . storage = storage
0 commit comments