Reputation: 147
i just get to the point and describe my problem . Given a square not parallel to the axis !
i have (x1,y1) and (x2,y2) and the distance beetween them dx(width/height of the square) i need to find the point (x,y) describe in the photo (cant upload photo) link to the image : the problem photo
first i tried the equation (x-x1)^2 + (y-y1)^2 = dx^2 (x-x2(^2 + (y-y2)^2 = 2 dx^2 but i cant manage to solve this equation when i try to code it ,
anyone have any idea's how to solve the problem in code or another equation or solution to find the point ?.
*i using c# 4,0
Upvotes: 0
Views: 939
Reputation: 35584
Very simple.
var dx = x2 - x1;
var dy = y2 - y1;
var rotatedDx = dy;
var rotatedDy = -dx;
x = x1 + rotatedDx;
y = y1 + rotatedDy;
Basically, you compute vector P1 -> P2 and rotate it by 90 degrees.
Upvotes: 2
Reputation: 496
You can solve it using complex numbers by representing the points on an Argand diagram. (I think)
Since its a square, the sides are equal and 90degrees apart you can do this. (Refer to dropbox picture)
https://www.dropbox.com/s/ymimimgkuzhkcub/IMAG3818.jpg?dl=0
A is point (x1, y1) with value x1 + (y1)i B is x2 + (y2)i P and Q are the locations of the 2 possible places (x, y) can be and they are x + yi. Solve the 2 equation in the picture for values of x and y.
Upvotes: 1