Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Other methods on moving sprite from one point to another point?  (Read 10385 times)

0 Members and 1 Guest are viewing this topic.

magneonx

  • Full Member
  • ***
  • Posts: 141
    • MSN Messenger - magnumneon04@hotmail.com
    • View Profile
Re: Other methods on moving sprite from one point to another point?
« Reply #15 on: August 14, 2013, 03:53:51 pm »
Great information posted here guys! I will actually try this implementation out as soon as I can and post once more if I had made it to work or I still got some few bugs. Thank you very much for the information!

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: Other methods on moving sprite from one point to another point?
« Reply #16 on: August 14, 2013, 05:44:30 pm »
Quote from: Nexus
The postcondition of the function is that it yields a unit vector, thus the caller expects the result to have length 1. When a zero vector is passed, this is impossible to achieve. Since the expectation cannot be met in any circumstances, the argument passed to unitVector() must be wrong.

So yes, crashing the application is the best way to immediately find the bug. Ignoring it will only let the error propagate and show up later, where it is much more difficult to find. I'm aware that there may be situations where one would really want a zero vector back; but in my opinion these cases are rare and should be handled explicitly by the user. The nice side effect of assert is that no performance is wasted to deal with situations that do not occur in correct code.

Actually, we're both I'm talking nonsense. These are floating point values, so assuming an IEEE 754 complaint environment, your implementation will simply return infinite in the zero vector case. Sorry to break the bad news. :P

Quote from: Nexus
And I don't think there is any ambiguity concerning where to place the assert. [...]

Well yes, clearly. I didn't mean debug assertions though. Anyway, this hardly seems like the appropriate thread to continue this discussion.

EDIT: It seems that I may have misunderstood your position. Obviously debug assertions should immediately halt the program.
« Last Edit: August 14, 2013, 06:22:29 pm by Lee R »

 

anything