0 Favourites

angle and distance problem

This forum is currently in read-only mode.
  • when i use the angle (a,a,b,b) and distance function, they work, but they dont return accurate results, is this normal?

    because once it gets past 179.9_ it goes into negatives? which isnt right is it?

    also when i use distance it return an innacurate number also, even if the objects are perfectly alligned its givng me 160 as its number?

  • Distance works fine for me... you sure you're hotspots are right or something?

    also, the angle goes negative depending on the direction of the object,

    either you can have angles going from 0 to 360 or -180 to 180

    You should be able to just forget about it, any time you'll probably need the angle (trig) it won't matter that it's going negative. Trig functions are periodic which means for example sin(x)=sin(x+360), so it won't actually make a difference to any calculations you have to do with the angle. (unless you want to display it from 0 to 360 or something).

  • Faggatron is right, angles can be outside the 0-360 range - 365 degrees "wraps around" back to 5 degrees again, because it's one full rotation plus 5 degrees. Same goes for negative, etc. If you want to display the result, add 180 to it Also, distance will give the distance in pixels, and if you're passing object coordinates, it will measure from their hot spots.

  • is distance doing this? or something different entirely

    sqrt(((A.x-B.x)^2)+((A.y-B.y)^2))

    cause its returning numbers based on quadrants, does it return actual distance?, or does it return the translation amount?

  • Yes, as you would expect the distance() expression uses the Pythagoras theorum as you have written. I'm sure it's working correctly, and it just returns the distance between two points - which is always positive and is unrelated to quadrants. I've used it for several things now and it works fine as far as I know!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Yes, as you would expect the distance() expression uses the Pythagoras theorum as you have written. I'm sure it's working correctly, and it just returns the distance between two points - which is always positive and is unrelated to quadrants. I've used it for several things now and it works fine as far as I know!

    i dunno why but i tested it using a text(s) as a counter, and i put one text to distance(blalblabla)

    and the other too the pytho but got different results?

  • I can't imagine why that would happen. Post a .cap and I'll see whats going on when I get my connection back.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)