Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Oct 20, 2023
1 parent 146aae0 commit 35e2e8e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Sources/ForceSimulation/forces/CenterForce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import NDTree
/// A force that drives nodes towards the center.
/// Center force is relatively fast, the complexity is `O(n)`,
/// where `n` is the number of nodes.
/// See [Collide Force - D3](https://d3js.org/d3-force/collide)
/// See [Collide Force - D3](https://d3js.org/d3-force/collide).
final public class CenterForce<NodeID, V>: ForceLike
where NodeID: Hashable, V: VectorLike, V.Scalar == Double {
public var center: V
Expand Down Expand Up @@ -40,6 +40,9 @@ where NodeID: Hashable, V: VectorLike, V.Scalar == Double {
extension Simulation {

/// Create a center force that drives nodes towards the center.
/// Center force is relatively fast, the complexity is `O(n)`,
/// where `n` is the number of nodes.
/// See [Collide Force - D3](https://d3js.org/d3-force/collide).
/// - Parameters:
/// - center: The center of the force.
/// - strength: The strength of the force.
Expand Down
4 changes: 2 additions & 2 deletions Sources/ForceSimulation/forces/CollideForce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct MaxRadiusTreeDelegate<NodeID, V>: NDTreeDelegate where NodeID: Hashable,
/// A force that prevents nodes from overlapping.
/// This is a very expensive force, the complexity is `O(n log(n))`,
/// where `n` is the number of nodes.
/// See [Collide Force - D3](https://d3js.org/d3-force/collide)
/// See [Collide Force - D3](https://d3js.org/d3-force/collide).
public final class CollideForce<NodeID, V>: ForceLike
where NodeID: Hashable, V: VectorLike, V.Scalar == Double {

Expand Down Expand Up @@ -184,7 +184,7 @@ extension Simulation {
/// Create a collide force that prevents nodes from overlapping.
/// This is a very expensive force, the complexity is `O(n log(n))`,
/// where `n` is the number of nodes.
/// See [Collide Force - D3](https://d3js.org/d3-force/collide)
/// See [Collide Force - D3](https://d3js.org/d3-force/collide).
/// - Parameters:
/// - radius: The radius of the force.
/// - strength: The strength of the force.
Expand Down
4 changes: 2 additions & 2 deletions Sources/ForceSimulation/forces/LinkForce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum LinkForceError: Error {

/// A force that represents links between nodes.
/// The complexity is `O(e)`, where `e` is the number of links.
/// See [Link Force - D3](https://d3js.org/d3-force/link)
/// See [Link Force - D3](https://d3js.org/d3-force/link).
final public class LinkForce<NodeID, V>: ForceLike
where NodeID: Hashable, V: VectorLike, V.Scalar == Double {

Expand Down Expand Up @@ -224,7 +224,7 @@ extension Simulation {
/// Create a link force that represents links between nodes. It works like
/// there is a spring between each pair of nodes.
/// The complexity is `O(e)`, where `e` is the number of links.
/// See [Link Force - D3](https://d3js.org/d3-force/link)
/// See [Link Force - D3](https://d3js.org/d3-force/link).
/// - Parameters:
/// - links: The links between nodes.
/// - stiffness: The stiffness of the spring (or links).
Expand Down
4 changes: 2 additions & 2 deletions Sources/ForceSimulation/forces/ManyBodyForce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct MassQuadtreeDelegate<NodeID, V>: NDTreeDelegate where NodeID: Hashable, V
/// A force that simulate the many-body force.
/// This is a very expensive force, the complexity is `O(n log(n))`,
/// where `n` is the number of nodes. The complexity might degrade to `O(n^2)` if the nodes are too close to each other.
/// See [Manybody Force - D3](https://d3js.org/d3-force/many-body)
/// See [Manybody Force - D3](https://d3js.org/d3-force/many-body).
final public class ManyBodyForce<NodeID, V>: ForceLike
where NodeID: Hashable, V: VectorLike, V.Scalar == Double {

Expand Down Expand Up @@ -312,7 +312,7 @@ extension Simulation {
/// This is a very expensive force, the complexity is `O(n log(n))`,
/// where `n` is the number of nodes. The complexity might degrade to `O(n^2)` if the nodes are too close to each other.
/// The force mimics the gravity force or electrostatic force.
/// See [Manybody Force - D3](https://d3js.org/d3-force/many-body)
/// See [Manybody Force - D3](https://d3js.org/d3-force/many-body).
/// - Parameters:
/// - strength: The strength of the force. When the strength is positive, the nodes are attracted to each other like gravity force, otherwise, the nodes are repelled like electrostatic force.
/// - nodeMass: The mass of the nodes. The mass is used to calculate the force. The default value is 1.0.
Expand Down

0 comments on commit 35e2e8e

Please sign in to comment.