Tag Info

Hot answers tagged

8

Conceptually, you can do that by animating the rotation of the cube (or as in Bloxorz, a cuboid) 90 degrees around one of its edges. You don't need move() at all! Side-on view of one rotation: Here's a seriously good JMonkeyEngine tutorial showing you how to rotate Boxes around pivot Nodes. It explains everything step-by-step. These are the important ...


7

As long as you're doing only uniform scaling, this is easy; you can simply extract each row (or column; it doesn't matter), of the 3x3 matrix. The scale factor will be the length of the row vector. If you normalize each row vector and construct a new matrix from the normalized rows, that will be the rotation part. (If you have a 4x4 matrix, you just do ...


6

The problem with rotations, is that, most people think of it in terms of Euler angles, since they are easy to understand. Yet most people forget the point that Euler angles are three sequential angles. Meaning that rotation around the first axis, will make next rotation be relative to the first original rotation, hence you cannot independently rotate a ...


5

Each orientation in 3D space can be represented by 2 distinct unit quaternions, q and -q (component-wise negated q). For instance the orientation represented by the 3x3 identity matrix I can be represented by 2 quaternions: q: { 0, 0, 0}, 1 -q: {-0, -0, -0}, -1 Both represent the same orientation in 3D space, their dot product is exactly -1, each of ...


5

Roy T. suggested to fix this changing the texture filtering settings, On LibGDX this can be found on Texture.setFilter or changing the Texture Params if you are using the AssetLoader. Set the filter params to TextureFilter.Linear and the problem should be fixed. For more on the matter, take a look at ...


4

1: Simple physics There will be a subtle difference in drag on either side*, because the side rotating into the wind will have greater dynamic pressure than the one that rotates with the wind. For an arbitrary shape, this will be somewhat difficult to calculate (although possible) for correct physics. You should not try, and approximate it instead. This ...


4

All 3D rotation must occur about some axis. That's what 3D rotation is. However, not all such rotation occurs about the Z axis. Rotation can be about any axis: X, Y, Z or an arbitrary axis not aligned with any of the principle axes of the coordinate system. What it sounds like you're referring to is the convention of rotating 2D shapes in a 2D plane about ...


4

To get a value inside [-pi,pi], you can add pi, do fmod, and subtract pi again. Here is one way that works. Unfortunately you still need to somehow test whether from - to is positive or negative before calling fmod: Scalar rotationBetween(Scalar from, Scalar to) { return (from > to) ? -pi + std::fmod(from - to + pi, pi * 2) : ...


4

If I understand correctly, you have three points A, B, C, and three points P, Q, R and you would like to know the affine transform (i.e. preserving distances) that transforms the first set into the second set. Finding the transform is straightforward; you just need to create two orthonormal bases from your sets of points, fill matrixes with the basis ...


3

It sounds like you're just getting the order of your matrix operations wrong. Assuming you have a circular collision volume you just want to make sure you rotate your sprite on it's centre axis. To do that you have to first have your sprite centred in the screen either by translating it to the centre or drawing it about the centre. Then you rotate it ...


3

It’s important to note that changing the co-ordinate system with rotate and translate do not affect anything that’s currently drawn into the canvas. It only affects subsequent drawing actions. var TO_RADIANS = Math.PI/180; function drawRotatedImage(image, x, y, angle) { // save the current co-ordinate system // before we screw with it ...


3

Your formula is correct. I would suggest normalising the quaternion at the end, though, or any stage involving interpolation will likely be messed up. What I believe is happening is that your up vector is (0, something, 0) and your normal vector is (0, -1, 0). In this very specific corner case (when the input vectors are opposite to each other) there is no ...


3

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying torques or anything. The function call could be something like this: body.setTransform(body.getPosition(),myDesiredAngle); Physics Solution If you want the player body to interact with bodies ...


3

Update: This was much harder to solve than I thought. However, I think I managed it to fix it, after trying 5 different approaches. So, the requirements really are that you have 3 source points and 3 corresponding destination points. And that you are sure that the distance between the points is conserved. And finally that the source points define a plane. ...


3

Instead of drawing the rotated image out to another image where you then draw that image out to Graphics to be displayed... why don't you draw directly to that Graphics object? This way it saves ALOT more time and doesn't waste memory. Graphics2D g2d = ... AffineTransform backup = g2d.getTransform(); AffineTransform trans = new AffineTransform(); ...


3

The simplest way to handle rotating 2D collisions is to use circles instead of rectangles. For most practical purposes, circles are a good approximation, simple to implement, and nobody will be able to tell the difference anyway. Two objects are colliding if the distance between the centres (using Pythagorean theorem) is less than the sum of the radiuses.


2

To illustrate, look at this image generated by Wolfram Alpha: You have your 3 local coordinate axes and you want to coincide any of them with a given forth vector (for instance (1/2, 1/2, 1/2) as in the image). To do that, you need to rotate your object. A rotation is best described as a combination of an angle and axis to rotate around. So how do we find ...


2

Doing that is possible, though I imagine insanely difficult, and since there is a better way, unnecessary. I'm also assuming that your using OpenGL 2.1, since glRotate was deprecated in OpenGL 3.x. So, Using OpenGL 2.1, instead of reversing the matrix from your physics API, I suggest you just plug that matrix straight into OpenGL. This can be done with ...


2

Make the moon a child of the planet object, and the planet a child of the star. Now, if the moon wasn't orbiting, it will stay with the planet in its orbit. You can easily rotate an arbitrary point around another arbitrary point with the following: public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Quaternion angle) { return ...


2

You can do this by creating the vertices for a sphere using one of the algorithms from this question, then you can orbit around it using the strategy described here. If you should use an engine or not isn't really something we can answer here. It depends on how long you want to spend creating the required functionality yourself. Typically, it's recommended ...


2

No, usually you don't undo transform by applying inverse. Because precision errors love to accumulate. Instead, either precalculate desired transform and set it directly, or reset current transform to identity and start over. This answer is api-agnostic. If there is way to manipulate current transform, then should be also way for resetting it. (I am not ...


2

Don't move the player's position directly in response to keyboard input. Instead always move the player forward relative to the direction it's facing, and lerp to different rotations based on keyboard input.


2

This gives me a nice slow rotation. But I am clueless how to tell Unity to stop at +30 degrees, reverse to -30 degrees, rotate again to +30, stop and repeat, etc, etc. I suggest you to use coroutines for that. There are several ways of course of doing that. The code could look more or less the following: IEnumerator LoopRotation(float angle) { ...


2

Each corner should be rotated around the center of the box. Typically this would be done by translating the box back to the origin, rotating, then translating back to the starting position. Imagine the points that make up the corners rotating around a circle: For rotating each point, see this answer.


2

I'd project the rotationDirection into the horizontal plane before you normalize it, something like... var rotationDirection = transform.position - rayHitPoint; rotationDirection.y = 0; rotationDirection.Normalize (); rotationTarget = Quaternion.LookRotation (rotationDirection); Note that the order of the subtraction used ...


2

It is actually supposed to be simple. There is an invisible anchor bullet moving like a normal game bullet would in a straight line (implementation not included). You have the angle alpha in which the anchor bullet is moving and its position px & py. You also have the amplitude (how far does the sine wave expands) and it's frequency (how fast does it go ...


2

Move your sub-components from the centre of mass to the pivot point: Find the centre of mass of your object. Compute the vector between your centre of mass and the pivot point of your object. Use that vector to move your cubes so that the centre of mass of your object is at the same place of the pivot point of your object. Perform your rotation. (Also ...


2

There are different ways to represent angles and you didn't mention which you use. So let's assume that you represent the directions of angles measured in Radiants between 0π and 2π and any angles outside of that allowed range are automatically transformed back into it by adding/subtracting 2π until they fit again. When the difference between this.angle and ...


2

You're going to have tons of questions regarding 3D math so I recommend you get the book Essential Math for Game Programmers, the 2nd Ed. I bought a copy myself and was reading it last night before bed. http://essentialmath.com/book.htm For your specific question you can use a rotation matrix to represent your object's orientation. You can concatenate this ...


2

As hinted by user concept3d, it is difficult to help you without further details about your implementation approach. I'm going to give it a shot nevertheless, but that means that I have to make some assumptions that may or may not be true for your code. In any event, I hope that the following is general enough that you can adapt it if necessary. The first ...



Only top voted, non community-wiki answers of a minimum length are eligible