Skip to content

angle()

mkraska edited this page Dec 18, 2024 · 4 revisions

angle(o1,o2)

  • o1 directional object 1
  • o2 directional object 2

returns the angle between two directional objects in radians.

Helper function for Feedback for Free Body Diagrams

Source

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)@}°.

Tryout Space

In order to try code snippets in jsfiddle,

  1. copy the code from the wiki page to the clipboard
  2. follow the link for the JSXGraph version you want to try
  3. Replace the code in the HTML section (contents of <p hidden id="init">) with the content of the clipboard
Clone this wiki locally