I wish I had paid attention to trig back in the early 70’s when I was drawing the SubMariner in math class. I have two guns I am trying to get to aim both barrels at the same point in 3D space WITHOUT creating a raycasting mess. The situation is this. I have two guns that are parallel to start with and are both controlled from a single slider that gives tilt to the X axis and another which rotates around the Y axis. These should both point at the same position in 3D space based on the range. IOW, if the range is 35 units then the barrels of both guns, if a shot is taken, would converge at the same point 35 units ahead of the gunnery station. Now, obviously infinite range is when both guns barrels are parallel. I have the aiming control set exactly between the two guns with each gun four units to the left or right of the aiming control. So what I figure I need to do is to use the center aiming control as the bisecting line of an equilateral triangle and when the height of the triangle is lengthened or shortened via the aiming range I can get the proper angle at the two base angles to feed to the guns. So, what is the ticket here… sin, cosin, tan, cotan?? I think I am gonna buy Trigonometry for Dummies…LOL!
I’m not sure I understand but to me it looks like you have a point C (the target) and 2 Points A and B (the turrets) in 3D space and you need the direction from each point A and B to C.
Direction vector A to C is C-A normalized.
Direction vector B to C is C-B normalized.
It should not be hard to use the vector to get the correct orientation on the turret.
Well from my old trig days it was “SOH, CAH, TOA” i.e. Sin=Opposite/Hypotenuse, Cos=Adjacent/Hypotenuse, Tan=Opposite/Adjacent
Opposite is the side opposite the angle you want. Adjacent is the one next to it (that isn’t the longest whioch is the Hypotenuse)
You want to find the angle ABC (from the mid point of AB to give a right angled triangle)
If distance between Turret A and B is 100, you have a mid point size of 50. If point C is at 200 you are missing the hypotenuse (i.e. length B to C).
So you therefore have the opposite and adjacent which means the you need Tan. This means that 50/200 = the tangent of the angle. So use ATan on the result then convert it into Degrees (from radians).
e.g. float angle=Degrees(Atan(50/200))
(you’ll need to check the function names as I’m doing it from memory)