Create a structure: points, the segments between them, and joints
Source:R/anistructure.R
anistructure.RdAn anistructure describes how the levels of one identity or temporal
variable relate: the keypoints of a skeleton, or the players of a team.
It has three parts, each optional beyond the first:
points — the members, levels of the variable it is attached to.
segments — directed links between two points, with an optional expected
length. Direction matters for joint angles: run limbs proximal to distal, and paired segments (left to right) the same way.joints — one measured angle each, between an ordered pair of segments
(a, b), with optional limitsmin,maxandrestin radians. The angle is 0 when the two segments point the same way. In 2D it is signed, turning fromatob. In 3D it is the included angle, or, whenaxisis given ("x","y","z"or a segment name), the signed angle about it. Several angles on the same pair of segments — flexion and abduction, say — are several joints with different axes.
Lengths and limits are recorded, not enforced: checks compare the data against them.
A structure is a template: it records no data and no variable until it
is attached to a frame with set_structure(), so one structure can be
reused across frames.
Usage
anistructure(
points = NULL,
segments = NULL,
joints = NULL,
root = NA_character_,
source = NA_character_,
citation = NA_character_,
license = NA_character_
)Arguments
- points
Character vector of point names. Defaults to the segment endpoints.
- segments
A data frame with
fromandto, and optionallysegment(defaults to"from-to") andlength; or a list ofc(from, to)pairs.- joints
A data frame with
aandb(segment names), and optionallyjoint(defaults to"a-b"),axis,min,maxandrest.- root
The point the structure hangs from when positions are rebuilt from segments.
NAif unset.- source, citation, license
Provenance of the structure.
Examples
anistructure(
segments = data.frame(
segment = c("thigh", "shin"),
from = c("hip", "knee"),
to = c("knee", "ankle")
),
joints = data.frame(joint = "knee", a = "thigh", b = "shin", min = 0, max = 2.5),
root = "hip"
)
# A team: points only, or points with links between them
anistructure(points = c("gk", "lb", "cb", "rb"))
anistructure(segments = list(c("lb", "cb"), c("cb", "rb")))