Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: ABS value in plane-line equation?

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2017

    ABS value in plane-line equation?


    Math question here about finding theta between a line and a plane. I've gotten by the dot cross result for the top of the equation and am working the "magnitude" of each in the bottom part. Question: should I take the ABS of the two sqrt functions below? The tutorial showed the denominator initially having the abs symbol || but disappeared from the work up. Perhaps its assumed.

    cos theta =

    n dot a
    sqrt(values...) sqrt(values)

    Should the sqrt be | sqrt(values...)| |sqrt(values...)|

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    The denominator is the product of the lengths, |n|*|a|. The arguments to the sqrt()s cannot be negative (they're the sum of squares, and squares can't be negative), and the result of sqrt() is always positive.

    Also, note that if theta is very close to zero, rounding errors can potentially result in calculating acos(1.00...001), which will be undefined (or NaN). For small angles, it may be better to use the magnitude of the cross product:

    sin(theta) = |na|/(|n|*|a|)

    This is accurate for small theta but inaccurate for theta close to a right angle.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts