if I have 2 coordinate pointA(x,y) and pointB(x,y)
I need to calculate the offset coordinate at specific distance and angle 90 deg and 270 deg. How can I?
Can't find the right formula.
How to get the coordinate of C,D,E,F?
Difference vector
dx = B.X - A.X
dy = B.Y - A.Y
Perpendicular vector
px = -dy
py = dx
Vector length (perhaps you have ready function Hypot
or alike function in your math library)
len = sqrt(px*px+py*py)
Normalized (unit length) vector
nx = px / len
ny = py / len
Now find points at distance dist
:
C.X = A.X + nx * dist
C.Y = A.Y + nY * dist
G.X = A.X - nx * dist
G.Y = A.Y - nY * dist
similar for points around B