fb_force() - mkraska/meclib GitHub Wiki
[txt, isOK]: fb_force(o, name, point, dir, toldeg, toldist, description)
txtfeedback textisOKflag for test resultolist of objectsnameexpected object name, as a string, or a list of strings if several names would be equally acceptable (e.g.["G","F_G"])pointa point the force's line of action must pass throughdirexpected direction, either a number (angle in degrees, standard math convention: 0 = +x axis, 90 = +y axis) or a direction vector[dx, dy]toldegdirection tolerance in degreestoldisttolerance for the distance between the force's line of action andpoint, in the same length units as the sketch (a bare number for now - no unit tag, though this could later become a[tol, "mm"]-style list if a question ever needs one)descriptionstring with text to identify the object for the user
This function provides feedback on a single, freely placed "force" object (e.g. a weight force, or a resultant the student places via forceGen) in the framework of Feedback for Free Body Diagrams. Unlike Feedback for "contact" / fb_bar(), the force is not resolved through a contact/support index - it is matched directly against o by name, since it is not tied to any particular contact point.
Checks done by fb_force():
- Is there exactly one
forceobject inothat isactiveand whose name matchesname(or one of the names inname, if a list was given)? - Does its direction match
dir, withintoldeg? On a mismatch, the feedback reports the actual deviation as a rounded degree value - the same wayfb_unit()reports a numeric deviation as a rounded percentage. - Does its line of action pass through
point, withintoldist? On a mismatch, the feedback reports the actual perpendicular distance as a rounded value, the same way the direction deviation is reported.
Typical PRT
Feedback variables:
obj: stackjson_parse(objects);
[text, isOK]: fb_force(obj, "G", [xO, r], -90, 2, 0.05, "Gewichtskraft: ");
PRT node
Algebraic test for isOK = true and feedback of {@text@} for both branches.