New answers tagged


Starting with the representation: [x2, y2]' = R(th) * [x1 y1]'; R(th) = [cos(th) -sin(th) sin(th) cos(th)] Which is basically a rotation operation on a vector. x2 and y2 are the rotated position of x1 and y1. The idea is to get cos(th) and sin(th) in terms of x1,x2,y1 and y2 variables. In order not to fall in to wrong quadrant, atan2 is used with ...


You can consider the building's rectangle as 4 lines, as shown in this image: Then you need the check if the road's line intersects any of the rectangle's lines. Here's another answer, which shows intersection between lines:


This looks like a choice of the wrong algorithm for the job. The code you've written does not find the closest transform in the collection. It does something more complicated. It returns the last transform in the list that's closer than at least one other transform in the list. So if you have three objects {close, medium, far}, then this will return medium,...


OK, this answer may sound a bit weird, but from what you've posted it looks like you're aiming the two parts separately at the same thing. So right now the gun barrel is probably rotating very weirdly, but is in the end still looking at the target as intended. Now the bottom part of the turret is working fine, which makes sense, since that part just looks ...

Top 50 recent answers are included