Tag Info

New answers tagged

1

I suggest moving the target slowly rather than the angle. Try this: Vector2 Target; // Interp is a value between 0 and 1. When 0, the target never moves. // When 1, the target moves instantaneously. Intermediate values cause the target // to move at different rates. void UpdateTarget(float interp) { Target = interp * Mouse.Position + (1 - interp) * ...


1

I think any linear function would be fine for this. You can keep two variables one for your spaceship's current angle spaceshipAngle = Math.PI*k, and one for the current angle that the user inputs with his cursor cursorAngle = Math.PI*p. And what you do is if (Math.Abs(Math.PI*k, Math.PI*p) < Math.PI) { if (Math.PI*k < Math.PI*p) k += ...


1

Your tilt line is stomping over whatever rotation the drone had and applying a new one. Just like writing: variable_a = 42; will replace whatever value was in variable_a before, the same happens with rotations, unless you use some type of combining operator like multiplication or Lerp. To fix this, you can build a rotation that takes both inputs into ...


0

All you really need is an exponential filter on each of the relevant variables. Have: // Translation parameters Vector3 target; // Rotation parameters float phi; float theta; float radius; // Values we want to smoothly interpolate to Vector3 nextTarget; float nextPhi; float nextTheta; float nextRadius; // Value between 0.0 and 1.0. If 1.0, no ...


1

If your problem is simply to deal with the fact that -10, 350, and 710 are all equivalent angles, that you may potentially get any desired angle, and that you never want to make a total rotation over 180 degrees, then: double Distance = DesiredAngle - CurrentAngle; // Let's bring Distance to its closest equivalent in the [-180..180] degrees range while ...


0

If you want rotation with lineal speed from one vector to another in shortest path I can suggest about using quanterions with SLERP http://en.wikipedia.org/wiki/Slerp If you want just rotate around x,y,z axis thats could be done with rotation matrix http://en.wikipedia.org/wiki/Rotation_matrix Nevertheless can you add your rotation code to question?


3

This is a late response, but I figured this question illustrates a common problem that many people are likely to run into and that deserves an answer. Quaternion rotation uses half the angle you want to rotate by. Since you (in this example case) are rotating by 90 degrees, the quaternion needs to calculate the sine and cosine of 45 degrees, both of which ...



Top 50 recent answers are included