This should be a simple math problem but the geometry class I've taken was > 10 years ago  and everything was forgotten.
btw, I am trying to find the coordinate I need to move to in order to get closer my target monster.
I think you need to do several things. you need to use the Pythagorean theorem to find the set of points X units from your original point (you'll get a set of points that form a circle).
You need the equation for the line, which you can get from the two points.
you need to solve that system of equations, which will give you two points.
you need to determine which of the two you want, probably by looking a which of the two is closer to the second point.
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Assuming the point is (xp,yp), then
From 2 point form I get the equation of the line as: (ypy1)^2 * (x1x2)^2 = (xpx1)^2 * (y1y2)^2 ......(1)
(I took square of the equation for easy substitiion with my 2nd equation)
From distance between 2 point formula: d^2 = (ypy1)^2 + (xp  x1)^2 .......(2)
And, now it is 2 equations with 2 unknown. It could be solved by eliminiation. Since, I got (ypy1)^2 in both equations, I can take the one in (2) and substitute it into (1) to get xp. And with xp known I just find yp from (1).
Is that correct?
assuming your two points are (0,2) and (8,2)..
you'll find two solutions...assuming your two points are (0,2) and (8,2), and you want a point 2 units away from (0,2) you'll find one at (2,2) and (2,2). the 'correct' one would be (2,2) since it's closer to (8,2).
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Alec Lee wrote:Thanks. I am working hard to recall my math knowledge. I show what I've done and see if it is correct or not:
Assuming the point is (xp,yp), then
From 2 point form I get the equation of the line as: (ypy1)^2 * (x1x2)^2 = (xpx1)^2 * (y1y2)^2 ......(1)
(I took square of the equation for easy substitiion with my 2nd equation)
From distance between 2 point formula: d^2 = (ypy1)^2 + (xp  x1)^2 .......(2)
And, now it is 2 equations with 2 unknown. It could be solved by eliminiation. Since, I got (ypy1)^2 in both equations, I can take the one in (2) and substitute it into (1) to get xp. And with xp known I just find yp from (1).
Is that correct?
I am not so sure about equation 1, it doesn't seem right, or else it is too complicated. equation (2) is correct.
may I suggest a slightly different way of doing.
ok, you have two unknowns x & y, and 4 "knowns" x1, y1, x2, y2
Since you have two unknowns you need two equations.
now the slope of the line is given by slope = (y2y1)/(x2x1). This is a known number, not a variable,.
since the point (x,y) is on the same line, it must fit into that formula, so the first equation is
A: (yy1)/(xx1) = slope.
now we get the second equation from pythagorus theorem
B: d^2 = (yy1)^2 + (xx1)^2
since you know what d is you now have two equations in two unknowns (x & y), and you should be able to sole this by substitution.
hopefuly that is a little clearer. my math is a little rusy too, but I'm pretty sure this is right.
So, i think that the creator of this post can answer my question:
I have two points with known cordinates A(x1,y1) and B(x2,y2).
So, my question is:
How to find a point C(x3,y3) which lies between A and B and is at location 9/10 of the length of AB.
Since my geometry classes were also long ago, would you mind keeping it simple and clear.
Thank you for the time.
Matt Cartwright wrote:just wondering ..
java.awt.geom.Point2D distanceSq(Point2D point)
Distance Formula
M
Yeah, except that method tells us the distance given two points, We know the distance, we don't know the 2nd point. So I don't see how we can use your method, but if you do, then I'm all ears. regards.
Let theta be the angle between the line and the xaxis; then theta is arctan((x2  x1) / (y2  y1)).
Then the point you are looking for is (x1 + d * cos(theta), y1 + d * sin(theta)).
You'll have to watch out for the case where y1 = y2, in which case theta is zero.
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Rocket Oven Kickstarter  from the trailboss
https://coderanch.com/t/695773/RocketOvenKickstartertrailboss
