March 14th, 2019, 07:48 AM  #1 
Newbie Joined: Mar 2019 From: Norway Posts: 1 Thanks: 0  Hypotenuse path from point A to B
Hi I'm working on a simpel path for a target in a game. I want the target to diagonally through the hypotenuse since I know the legs. The target as the coordinates of point A, being the start point, and point B, the end point. The target also has a speed on which it should move n amount of pixels per frame. My simple formula is pretty much newXCoordinate=(legX/hypotenuse)*speed and newYCoordinate = (legY/hypotenuse)*speed. In reality it move like the yellow like shown in the image attached. I'm guessing it's because each pixel movement is calculated as integers and not float number. So the target can't move in decimal pixels but only whole pixels at a time. An alternative would be to calculate with memory. Example, for each 2 xaxis pixels the target move, it also moves 3 pixel in the yaxis, but every other time the target moves in the xaxis it needs to move 4 pixels in the yaxis. Or does anyone have a better idea? 

Tags 
hypotenuse, hypothenuse, path, point 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Mystery Hypotenuse  Bio  Math  9  March 13th, 2017 10:59 PM 
Is it possible to find the hypotenuse?  davedave  Geometry  6  October 1st, 2016 11:40 PM 
path dependent function with a definite path  aise5668  Real Analysis  3  March 5th, 2012 06:36 PM 
Point of intersection of hypotenuse  FeebleBrain  Algebra  4  January 24th, 2011 12:48 AM 
If only given hypotenuse and right angle.....  bonsai6  Algebra  2  August 23rd, 2007 10:19 AM 