Jump to content
  • Advertisement

Christer Ericson

  • Content Count

  • Joined

  • Last visited

Community Reputation

840 Good

About Christer Ericson

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Christer Ericson

    Plane equation, + or - D

    mathematical, Dirk already gave a good answer to your question, but I wanted to stress that it is a good idea to try to work "coordinate free." I.e. where possible, avoid formulas that expose the x, y, z coordinates, like the above "plane equation" does. Instead, like Dirk said (and as I also discuss in my book), it's better to consider planes as being defined by the set of vectors that are perpendicular to the plane normal, and that have an "origin" defined by any point on the plane.   In other words, let N be the plane normal, let P be any point on the plane, and let X be all other points on the plane. Then we can express this relationship as:   Dot(N, X - P) = 0.   I.e. the vectors N and X - P need to be perpendicular.   You can expand that expression in two ways:   Dot(N, X - P) = Dot(N, X) - Dot(N, P) = ... = n.x * x.x + n.y * x.y + n.z * x.z - d or Dot(N, X - P) = Dot(N, X) + Dot(N, -P) = ... = n.x * x.x + n.y * x.y + n.z * x.z + d   Which is why you see the expanded explicit-coordinate plane equation sometimes with '-' and sometimes with '+'. Both are correct, and the difference is just that the 'd' constant is negated between the two expressions.   Hope that helps.
  2. Christer Ericson

    Need Explanation With Distance Between Two Segments

    All of this is explained in section 5.1.9 of my book. The code uses the notation that the text uses, and the text contains both explanations and derivations of the math, that is then expressed in code. The expression (b*f - c*e) / denom is solving an equation, to determine where on the segments the closest points lie. In order to understand it, you need to invest time into understanding the math behind it (said math also being explained in the book).   The Chapter 3 math primer is there to help provide some math background, but is fundamentally not a replacement for the study of a proper elementary linear algebra (ELA) textbook. I described Cramer's rule for solving systems of linear equations because it is -- relatively -- very easy to describe and understand. The Gaussian elimination algorithm I deemed would take too much space and time to go through, and people would be better off looking it up online or consulting an ELA textbook. It's really not that hard though, I recommend looking it up!   I caveat all of this on pages 5-6. E.g. "To turn the presented code into real production code, some additions may be necessary. For example, tests for division by zero are not always performed to avoid going into details that would hamper the understanding of the overall approach. Similarly, some code tests may require tolerance values to be added for full robustness."   The code samples aren't intended to be used as-is, but as a starting point for someone to write their own version, that matches their own needs.     Again, see pages 5-6 that clarify this. Notably the reference to the reader to apply the practices of Chapter 11 to the code samples, if they want production-ready code.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!