angle() - mkraska/meclib GitHub Wiki
angle(o1,o2)
o1
directional object 1o2
directional object 2
returns the angle between two directional objects in radians.
Helper function for Feedback for Free Body Diagrams
Example
Let's say you want to check if a force object from some interactive input has the correct direction. In the question variables you define the system sketch with the movable object and provide index values for later access. Don't forget to include the meclib macro file.
initdata: ...
i_o: 3;
tansdata: ...
ti_o: 3;
stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_fbd.mac");
This is what you do in the feedback variables:
obj: stackjson_parse(objects);
a: angle(obj[i_o, tansdata[ti_o]);
In the answer test you do a numeric comparison (NumAbsolute) with SAns a
and TAns 0
True feedback:
The object has the correct direction.
False feedback:
The direction of the object is not correct. The angle is off by {@dispdp(a*180/pi,1)@}°.