My Math Forum  

Go Back   My Math Forum > High School Math Forum > Geometry

Geometry Geometry Math Forum


Reply
 
LinkBack Thread Tools Display Modes
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 x-axis pixels the target move, it also moves 3 pixel in the y-axis, but every other time the target moves in the x-axis it needs to move 4 pixels in the y-axis. Or does anyone have a better idea?
Attached Images
File Type: png Greenshot 2019-03-14 16.00.04.png (16.3 KB, 2 views)
UyQTran is offline  
 
Reply

  My Math Forum > High School Math Forum > Geometry

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





Copyright © 2019 My Math Forum. All rights reserved.