an.stage.rigid#
Rigid falls in the stage plane: a let-go item’s flight, landing, tip and bounce; a body toppling about a contact.
Two motions, both of a rigid drawing under gravity (stage px, y down, an
angle turning +x toward +y, clockwise on screen), shared by the hold
layer’s release (an.stage.hold) and the topple pass
(an.stage.topple):
A drop (
drop_track()): the item’s centre flies a parabola from where it was let go, spinning at a CONSTANT rate (a body in the air has no torque on it), until its lowest point touches the floor slightly short of its rest angle; it then tips about that point onto its resting side (rotation about a fixed contact under gravity, the impact’s angular momentum carried over), bounces a little (bounce, a coefficient of restitution) and comes to rest. A flat landing bounces straight up instead. Nothing eases into its rest pose: the old release’s smooth-step rotation was what made a dropped musket read as floating.A pivot fall (
pivot_fall()): a body turning about a fixed contact point under gravity from an angular velocity, until astopfunction of its turn says it hit something (the floor, another body, a target).
Pure functions over points; no stage types. The item is a cloud of points
(its ink) about its centre of mass, at a reference pose; a pose is
(cx, cy, turn) with turn the rotation from that reference.
>>> rod = [(-50.0, 0.0), (50.0, 0.0)]
>>> round(inertia(rod), 1) # a uniform rod of length 100: L**2 / 12
833.3
Module Attributes
the share of its speed it keeps when it bounces (a clatter, not a rubber ball). |
Functions
|
The angles a rigid drawing can lie at on a floor: each side of its ink's convex hull turned to be the bottom, where its centre (the origin of |
|
The motion of a rigid item let go ( |
|
Moment of inertia per unit mass about the centre (px²), from ink points on the drawing's outline: a third of their mean squared distance (a uniform rod's |
|
A body whose centre is at |
Classes
|
A let-go item's motion from the instant it is let go ( |
|
A body turning about a fixed |
- an.stage.rigid.DFLT_BOUNCE: float = 0.15#
the share of its speed it keeps when it bounces (a clatter, not a rubber ball).
- Type:
Coefficient of restitution of a let-go item on the floor
- class an.stage.rigid.DropTrack(touch, rest, bounces, angle, floor, _phases, _scale)[source]#
Bases:
objectA let-go item’s motion from the instant it is let go (
t = 0):pose()gives(cx, cy, angle, scale_x, scale_y)at anyt.touchis when it first touches the floor,restwhen it stops moving,bounceswhen each bounce lands (all seconds from the let-go);floorthe line it comes to rest on.
- class an.stage.rigid.PivotFall(pivot, centre0, times, turns, duration, omega_end, stopped)[source]#
Bases:
objectA body turning about a fixed
pivot:turn(t)andcentre(t)fortfrom 0 toduration;omega_endis its angular velocity when it stopped,stoppedwhetherstopsaid so (else the cap or the end).
- an.stage.rigid.drop_track(points, **kw)[source]#
The motion of a rigid item let go (
_drop_once()has the parameters); a tosstoss_xis aimed so that the item comes to REST, after the tip onto its side, centred on thatx.>>> rod = [(-50.0, 0.0), (50.0, 0.0), (-50.0, 4.0), (50.0, 4.0)] >>> tr = drop_track(rod, centre=(0.0, 0.0), velocity=(0.0, 0.0), angle=0.6, ... rest_angle=0.0, ground=200.0, gravity=980.0, toss_x=120.0, arc=30.0) >>> round(tr.pose(tr.rest)[0], 3) 120.0
- Return type:
- an.stage.rigid.inertia(points)[source]#
Moment of inertia per unit mass about the centre (px²), from ink points on the drawing’s outline: a third of their mean squared distance (a uniform rod’s
L²/12, a square’sa²/6).>>> round(inertia([(-1.0, -1.0), (1.0, -1.0), (1.0, 1.0), (-1.0, 1.0)]), 3) # a 2x2 square 0.667
- Return type:
- an.stage.rigid.pivot_fall(centre, pivot, *, gravity, omega=0.0, inertia_cm=1.0, stop=None, cap=4.0)[source]#
A body whose centre is at
centreturning aboutpivotundergravity(px/s², down), from angular velocityomega(rad/s, clockwise positive), untilstop(turn)changes sign from positive (the gap to whatever it hits; the crossing is found to a fraction of a step) orcapseconds pass.The equation is the rigid pendulum’s, inverted:
I_p θ'' = g r_xwithrfrom the pivot to the centre andI_p = I_cm + |r|².>>> f = pivot_fall((0.0, -100.0), (0.0, 0.0), gravity=980.0, omega=0.5, ... inertia_cm=833.3, stop=lambda a: math.pi / 2 - a) >>> f.stopped, round(f.turn(f.duration), 3), 0.8 < f.duration < 1.2 (True, 1.571, True)
- Return type:
- an.stage.rigid.stable_angles(points)[source]#
The angles a rigid drawing can lie at on a floor: each side of its ink’s convex hull turned to be the bottom, where its centre (the origin of
points) stands over that side with at leastLIE_MINto tip before it falls off. Radians in(-pi, pi].>>> sorted(round(a, 3) for a in stable_angles([(-50.0, -2.0), (50.0, -2.0), (50.0, 2.0), (-50.0, 2.0)])) [0.0, 3.142]