pylinkage.joints package
Submodules
pylinkage.joints.crank module
Crank joint definition.
A crank is a driver joint that rotates around a fixed anchor point. This is a thin wrapper around the solver’s solve_crank function.
- class pylinkage.joints.crank.Crank(x: float | None = None, y: float | None = None, joint0: Joint | tuple[float, float] | None = None, distance: float | None = None, angle: float | None = None, name: str | None = None)
Bases:
JointDefine a crank (rotary driver) joint.
The crank rotates around its anchor point (joint0) at a constant angular velocity. It is the primary driver for linkage mechanisms.
- angle: float | None
- get_constraints() tuple[float | None]
Return the distance to the center of rotation.
- r: float | None
- reload(dt: float = 1) None
Make a step of crank using solver function.
- Parameters:
dt – Fraction of steps to take (Default value = 1).
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None) None
First joint anchor and fixed distance.
- Parameters:
joint – Joint to set as anchor.
distance – Distance from the joint. (Default value = None).
- set_constraints(distance: float | None = None, *args: float | None) None
Set geometric constraints, only self.r is affected.
- Parameters:
distance – Distance from the reference point. (Default value = None).
args – Unused, but preserves the object structure.
pylinkage.joints.fixed module
Fixed joint (deterministic constraint).
A fixed joint has a position fully determined by its two parent joints with no ambiguity. It uses polar coordinates relative to the line between the two parents.
This is a thin wrapper around the solver’s solve_fixed function.
- class pylinkage.joints.fixed.Fixed(x: float | None = None, y: float | None = None, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, distance: float | None = None, angle: float | None = None, name: str | None = None)
Bases:
JointFixed joint - deterministic polar constraint.
The position is fully determined by: - joint0: Origin point - joint1: Reference point for angle measurement - r: Distance from joint0 - angle: Angle offset from the joint0→joint1 direction
Unlike Revolute (RRR dyad), this has a unique solution.
- angle: float | None
- get_constraints() tuple[float | None, float | None]
Return the constraining distance and angle parameters.
- r: float | None
- reload(dt: float = 1) None
Compute position using solver (deterministic constraint).
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None, angle: float | None = None) None
First joint anchor and characteristics.
- Parameters:
joint – Joint to set as anchor.
distance – Distance from the joint. (Default value = None).
angle – Angle in radians. (Default value = None).
- set_anchor1(joint: Joint | tuple[float, float]) None
Second joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_constraints(distance: float | None = None, angle: float | None = None, *args: float | None) None
Set geometric constraints.
- Parameters:
distance – Distance from joint0. (Default value = None).
angle – Angle in radians. (Default value = None).
args – Unused, but preserves the object structure.
pylinkage.joints.joint module
Definition of the different joints used for pylinkage.
- class pylinkage.joints.joint.Joint(x: float | None = 0, y: float | None = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, name: str | None = None)
Bases:
ABCGeometric constraint expressed by two joints.
Abstract class should always be inherited.
- coord() tuple[float | None, float | None]
Return cartesian coordinates.
- abstractmethod get_constraints() tuple[float | None, ...]
Return geometric constraints applying to this Joint.
- name: str
- abstractmethod reload(dt: float = 1) None
Recompute joint coordinates based on constraints and parent joints.
- Parameters:
dt – Time step or fraction of movement. The default is 1.
- abstractmethod set_constraints(*args: float | None) None
Set geometric constraints applying to this Joint.
- set_coord(*args: float | None | tuple[float, float] | tuple[float | None, float | None]) None
Take a sequence or two scalars, and assign them to object x, y.
- Parameters:
args – Coordinates to set, either as two elements or as a tuple of 2 elements.
- x: float | None
- y: float | None
- class pylinkage.joints.joint.Static(x: float = 0, y: float = 0, name: str | None = None)
Bases:
JointSpecial case of Joint that should not move.
Mostly used for the frame.
- get_constraints() tuple[()]
Return an empty tuple.
- reload(dt: float = 1) None
Do nothing, for consistency only.
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float]) None
First joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_anchor1(joint: Joint | tuple[float, float]) None
Second joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_constraints(*args: float | None) None
Do nothing, for consistency only.
- Parameters:
args – Unused.
pylinkage.joints.prismatic module
Definition of a prismatic joint (RRP dyad).
A prismatic joint is positioned at the intersection of a circle and a line. The circle is centered at a revolute anchor, and the line is defined by two other joints. This corresponds to an RRP (two revolute, one prismatic) dyad in Assur group theory.
This is a thin wrapper around the solver’s solve_linear function.
- class pylinkage.joints.prismatic.Linear(*args: object, **kwargs: object)
Bases:
PrismaticDeprecated alias for Prismatic joint.
Deprecated since version Use:
Prismaticinstead. TheLinearname will be removed in a future version.- joint2: pl_joint.Joint | pl_joint.Static | None
- revolute_radius: float | None
- class pylinkage.joints.prismatic.Prismatic(x: float = 0, y: float = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, joint2: Joint | tuple[float, float] | None = None, revolute_radius: float | None = None, name: str | None = None)
Bases:
JointPrismatic joint (RRP dyad) - circle-line intersection.
The position is computed as the intersection of: - Circle: centered at joint0 with radius revolute_radius - Line: passing through joint1 and joint2
When two solutions exist, the nearest to the current position is chosen (hysteresis for continuity during simulation).
- get_constraints() tuple[float | None]
Return the only distance constraint for this joint.
- reload(dt: float = 1) None
Compute position using solver (RRP dyad - circle-line).
- Parameters:
dt – Unused, but preserves the object structure.
- revolute_radius: float | None
- set_constraints(distance0: float | None = None, *args: float | None) None
Set the only distance constraint for this joint.
- Parameters:
distance0 – Distance from joint0. (Default value = None).
args – Unused, but preserves the object structure.
pylinkage.joints.revolute module
Definition of a revolute joint (RRR dyad).
A revolute joint is positioned at the intersection of two circles, each centered at a parent joint. This corresponds to an RRR (three revolute joints) dyad in Assur group theory.
This is a thin wrapper around the solver’s solve_revolute function.
- class pylinkage.joints.revolute.Pivot(x: float = 0, y: float = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, distance0: float | None = None, distance1: float | None = None, name: str | None = None)
Bases:
RevoluteRevolute Joint definition.
Deprecated since version 0.6.0: This class has been deprecated in favor of Revolute which has a standard name. It will be removed in PyLinkage 0.7.0.
- r0: float | None
- r1: float | None
- class pylinkage.joints.revolute.Revolute(x: float = 0, y: float = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, distance0: float | None = None, distance1: float | None = None, name: str | None = None)
Bases:
JointRevolute joint (RRR dyad) - circle-circle intersection.
The position is computed as the intersection of two circles: - Circle 1: centered at joint0 with radius r0 - Circle 2: centered at joint1 with radius r1
When two solutions exist, the nearest to the current position is chosen (hysteresis for continuity during simulation).
- circle(joint: Joint) tuple[float, float, float]
Return the first link between self and parent as a circle.
- Parameters:
joint – Parent joint you want to use.
- Returns:
Circle is a tuple (abscissa, ordinate, radius).
- get_constraints() tuple[float | None, float | None]
Return the two constraining distances of this joint.
- r0: float | None
- r1: float | None
- reload(dt: float = 1) None
Compute position using solver (RRR dyad - circle-circle).
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None) None
Set the first anchor for this Joint.
- Parameters:
joint – The joint to use as anchor.
distance – Distance to keep constant from the anchor. The default is None.
- set_anchor1(joint: Joint | tuple[float, float], distance: float | None = None) None
Set the second anchor for this Joint.
- Parameters:
joint – The joint to use as anchor.
distance – Distance to keep constant from the anchor. The default is None.
- set_constraints(distance0: float | None = None, distance1: float | None = None, *args: float | None) None
Set geometric constraints.
- Parameters:
distance0 – Distance to the first reference (Default value = None).
distance1 – Distance to the second reference (Default value = None).
args – Unused, but preserves the object structure.
pylinkage.joints.static module
Static joint definition file.
- class pylinkage.joints.static.Static(x: float = 0, y: float = 0, name: str | None = None)
Bases:
JointSpecial case of Joint that should not move.
Mostly used for the frame.
- get_constraints() tuple[()]
Return an empty tuple.
- reload(dt: float = 1) None
Do nothing, for consistency only.
- Args:
dt: Unused, but preserves the object structure.
- set_anchor0(joint: pl_joint.Joint | Coord) None
First joint anchor.
- Args:
joint: Joint to set as anchor.
- set_anchor1(joint: pl_joint.Joint | Coord) None
Second joint anchor.
- Args:
joint: Joint to set as anchor.
- set_constraints(*args: float | None) None
Do nothing, for consistency only.
- Args:
args: Unused.
Module contents
Definition of joints.
- class pylinkage.joints.Crank(x: float | None = None, y: float | None = None, joint0: Joint | tuple[float, float] | None = None, distance: float | None = None, angle: float | None = None, name: str | None = None)
Bases:
JointDefine a crank (rotary driver) joint.
The crank rotates around its anchor point (joint0) at a constant angular velocity. It is the primary driver for linkage mechanisms.
- angle: float | None
- get_constraints() tuple[float | None]
Return the distance to the center of rotation.
- r: float | None
- reload(dt: float = 1) None
Make a step of crank using solver function.
- Parameters:
dt – Fraction of steps to take (Default value = 1).
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None) None
First joint anchor and fixed distance.
- Parameters:
joint – Joint to set as anchor.
distance – Distance from the joint. (Default value = None).
- set_constraints(distance: float | None = None, *args: float | None) None
Set geometric constraints, only self.r is affected.
- Parameters:
distance – Distance from the reference point. (Default value = None).
args – Unused, but preserves the object structure.
- class pylinkage.joints.Fixed(x: float | None = None, y: float | None = None, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, distance: float | None = None, angle: float | None = None, name: str | None = None)
Bases:
JointFixed joint - deterministic polar constraint.
The position is fully determined by: - joint0: Origin point - joint1: Reference point for angle measurement - r: Distance from joint0 - angle: Angle offset from the joint0→joint1 direction
Unlike Revolute (RRR dyad), this has a unique solution.
- angle: float | None
- get_constraints() tuple[float | None, float | None]
Return the constraining distance and angle parameters.
- r: float | None
- reload(dt: float = 1) None
Compute position using solver (deterministic constraint).
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None, angle: float | None = None) None
First joint anchor and characteristics.
- Parameters:
joint – Joint to set as anchor.
distance – Distance from the joint. (Default value = None).
angle – Angle in radians. (Default value = None).
- set_anchor1(joint: Joint | tuple[float, float]) None
Second joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_constraints(distance: float | None = None, angle: float | None = None, *args: float | None) None
Set geometric constraints.
- Parameters:
distance – Distance from joint0. (Default value = None).
angle – Angle in radians. (Default value = None).
args – Unused, but preserves the object structure.
- class pylinkage.joints.Linear(*args: object, **kwargs: object)
Bases:
PrismaticDeprecated alias for Prismatic joint.
Deprecated since version Use:
Prismaticinstead. TheLinearname will be removed in a future version.- joint2: pl_joint.Joint | pl_joint.Static | None
- revolute_radius: float | None
- class pylinkage.joints.Prismatic(x: float = 0, y: float = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, joint2: Joint | tuple[float, float] | None = None, revolute_radius: float | None = None, name: str | None = None)
Bases:
JointPrismatic joint (RRP dyad) - circle-line intersection.
The position is computed as the intersection of: - Circle: centered at joint0 with radius revolute_radius - Line: passing through joint1 and joint2
When two solutions exist, the nearest to the current position is chosen (hysteresis for continuity during simulation).
- get_constraints() tuple[float | None]
Return the only distance constraint for this joint.
- reload(dt: float = 1) None
Compute position using solver (RRP dyad - circle-line).
- Parameters:
dt – Unused, but preserves the object structure.
- revolute_radius: float | None
- set_constraints(distance0: float | None = None, *args: float | None) None
Set the only distance constraint for this joint.
- Parameters:
distance0 – Distance from joint0. (Default value = None).
args – Unused, but preserves the object structure.
- class pylinkage.joints.Revolute(x: float = 0, y: float = 0, joint0: Joint | tuple[float, float] | None = None, joint1: Joint | tuple[float, float] | None = None, distance0: float | None = None, distance1: float | None = None, name: str | None = None)
Bases:
JointRevolute joint (RRR dyad) - circle-circle intersection.
The position is computed as the intersection of two circles: - Circle 1: centered at joint0 with radius r0 - Circle 2: centered at joint1 with radius r1
When two solutions exist, the nearest to the current position is chosen (hysteresis for continuity during simulation).
- circle(joint: Joint) tuple[float, float, float]
Return the first link between self and parent as a circle.
- Parameters:
joint – Parent joint you want to use.
- Returns:
Circle is a tuple (abscissa, ordinate, radius).
- get_constraints() tuple[float | None, float | None]
Return the two constraining distances of this joint.
- r0: float | None
- r1: float | None
- reload(dt: float = 1) None
Compute position using solver (RRR dyad - circle-circle).
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float], distance: float | None = None) None
Set the first anchor for this Joint.
- Parameters:
joint – The joint to use as anchor.
distance – Distance to keep constant from the anchor. The default is None.
- set_anchor1(joint: Joint | tuple[float, float], distance: float | None = None) None
Set the second anchor for this Joint.
- Parameters:
joint – The joint to use as anchor.
distance – Distance to keep constant from the anchor. The default is None.
- set_constraints(distance0: float | None = None, distance1: float | None = None, *args: float | None) None
Set geometric constraints.
- Parameters:
distance0 – Distance to the first reference (Default value = None).
distance1 – Distance to the second reference (Default value = None).
args – Unused, but preserves the object structure.
- class pylinkage.joints.Static(x: float = 0, y: float = 0, name: str | None = None)
Bases:
JointSpecial case of Joint that should not move.
Mostly used for the frame.
- get_constraints() tuple[()]
Return an empty tuple.
- reload(dt: float = 1) None
Do nothing, for consistency only.
- Parameters:
dt – Unused, but preserves the object structure.
- set_anchor0(joint: Joint | tuple[float, float]) None
First joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_anchor1(joint: Joint | tuple[float, float]) None
Second joint anchor.
- Parameters:
joint – Joint to set as anchor.
- set_constraints(*args: float | None) None
Do nothing, for consistency only.
- Parameters:
args – Unused.