Geometry

I’ll probably have a number of questions, but my first is how to do calculations with units and Fixed-Point Maths. For instance, to find the slope of a line between two points:

To decide what real number is the slope of the line between/from (A - a thing) and/to (B - a thing): decide on (y-coord of A - y-coord of B) / (x-coord of A - x-coord of B).

Where x-coord and y-coord are lengths (I’m using Metric Units, naturally). But this returns a number instead of a real number, so you get an error. You can’t use the Fixed-Point Maths calculations (real subtract, real divided by) because those can’t apparently handle units. And you can’t just get the answer as an integer and convert it to a real number, because it’s very likely a small fraction.

Looking at the documentation, I can’t tell right off if there’s a way to convert numbers to real numbers. If there is, can you:

  • divide each length by the same base length (1 inch, 1 foot, 1 meter, whatever) to derive a number
  • convert each number to a real number
  • carry out the division from there

If not, you can create numbers from text, so I’d try:

  • divide each length by base length to get a number
  • put each number into text (this is the part I haven’t done before, so I’m not entirely sure of the logistics)
  • convert the text to real numbers
  • carry out the division from there

This method will work. Numbers can be converted to real numbers by using “X as a real number”, e.g.:

decide on ((A_y as a real number) real minus (B_y as a real number) ) real divided by ((A_x as a real number) real minus (B_x as a real number))

(Actually, the correct locution might be “X as a fixed point number”–I don’t recall.)

–Erik