1

I am making a game and I want the camera to be at the side of the two players, approximately 10 metres from the centre point between the two with rotation so it is 90 degrees from the line between the two, example picture here:

http://i43.tinypic.com/2008w89.jpg

Sam
  • 1,509
  • 3
  • 19
  • 28
user576820
  • 1,289
  • 2
  • 11
  • 13

1 Answers1

0

Let's coordinates of given points are (Ax,Ay), (Bx,By)

In vector form:

C = (B+A)/2 + - 1/2 * Perpendicular(B-A)

BAx = Bx-Ax ; BAy = By-Ay

BAPerpX = - BAy ; BAPerpY = BAx

Cx = Ax/2 +Bx/2 +- BAPerpX/2

Cy = Ay/2 +By/2 +- BAPerpY/2

Choose sign '+' or '-', and point C will lie to left or to right relative to A-B line

MBo
  • 77,366
  • 5
  • 53
  • 86
  • I already solved it about 1/2 hour after positing, damn Stackoverlow won't let me post it for 8 hours :/ – user576820 Nov 24 '11 at 10:42
  • I'll mark yours as correct though since you went to the trouble of answering and my code is LUA so may not be universal unlike yours, thanks. – user576820 Nov 24 '11 at 10:43