Peter Hickman
3/31/2008 9:51:00 AM
Phillip Gawlowski wrote:
> actor1 = Gondor::AI::Actor.new(:x => 0,:y => 0,:z => 0)
> actor2 = Gondor::AI::Actor.new(:x => 16, :y => 16, :z => 16)
> actor1.distance(actor2)
> produces: 3.74165738677394
>
> actor1 = Gondor::AI::Actor.new(:x => 1,:y => 1,:z => 1)
> actor2 = Gondor::AI::Actor.new(:x => 15, :y => 15, :z => 15)
> produces: 4.0
>
> Why is that? From my understanding, these results should be identical
> (The algebraic sign is eliminated by exponent 2, everything else is
> addition).
If my reading is correct the distances should be different. I am not
saying that the reported distances are correct only that they should be
different. Take the x axis for example:
(0 - 16) * (0 - 16) = 256
(1 - 15) * (1 - 15) = 196
What you probably meant was:
actor1 = Gondor::AI::Actor.new(:x => 0,:y => 0,:z => 0)
actor2 = Gondor::AI::Actor.new(:x => 15, :y => 15, :z => 15)
should be the same distance as:
actor1 = Gondor::AI::Actor.new(:x => 1,:y => 1,:z => 1)
actor2 = Gondor::AI::Actor.new(:x => 16, :y => 16, :z => 16)