Hot answers tagged

3

In the case of a puzzle like this you can animate the rotation then reset the model back to its original position but with the cube's stickers rotated. Look at it like cheating with a real puzzle by moving the stickers. You'll have to make it possible to change the stickers' colors. This can be done with material colors or a dynamic texture. And this way ...


2

You need to: "Move" the origin - translate the ship by -CenterPos (the position of central character) Do the desired rotating Move back translating by CenterPos tip: automate the process by creating a function like RotateAround(Point) see any "transformation composition" tutorial for detailed explanation.


2

In this case, the matrix is generated from the call to Matrix.CreateRotationZ, which is a function (a static method of the Matrix class). It creates a 4x4 tranformation matrix which describe a rotation about the Z axis. The formula for constructing that matrix can be seen here, as Rz. Extending that the 4x4 form used for the Matrix class, it would look like ...


2

You will need a forward vector which represent the forward direction of your ship, and the velocity of your ship. // Stuff that you need (or already have) vec3 shipForwardVector; // This is according to your game infrastructure // and ship model; make it a unit vector. mat4 worldSpaceRotationMat; // assuming ship!.transform is only ...


1

Have a currentRotation and a desiredRotation you will also want some helper function to give you the shortest angle distance, so let's just call that angleDist or whatever. (You want that because sometimes going clockwise is shorter or vice versa). Then all you need is to interpolate between them somehow. currentRotation += expFactor * ...


1

I realized why this happens. When the quaternion is made, the axis is multiplied by sinus of the half angle. When the rotation gets to 360 that value will be zero so the axis information will be lost.


1

We can achieve this through trigonometry. Angle calculation (pseudo code): public double calculateAngle(double yourX, double yourY, double targetX, double targetY) { double distanceX = yourX - targetX; double distanceY = yourY - targetY; return Math.toDegrees(atan2(distanceY, distanceX)); //For radians just remove 'Math.toDegrees()' around ...


1

The steps required are; Calculate velocity based on the speed and the current direction of travel. Add velocity to position. Calculate difference between direction of travel and direction to target. Add the angle to the rotation of the missile. If the Sprite class is defined as; public static class Sprite { public double rotation; public double ...


1

All you need is basic trigonometry. Unfortunately I don't have time to explain, but here is the formulas. x = speed * sin(rotation) y = speed * -cos(rotation) This is if positive y is down and positive x is to the left, or x = speed * -sin(rotation) y = speed * -cos(rotation) If positive y is down and positive x is to the right. Please note whether ...


1

It's unclear where your issue lies. To rotate a vector about the origin, you create a rotation matrix, and then you multiply the vertex by the matrix. In order to create the rotation matrix, you need a rotation axis and an angle. With glm, you can do it this way: glm::vec3 v3RotAxis( 0.0f, 0.0f, 1.0f ); // Rotate about z+ float angleRad = ...


1

In Unity, the inertia tensor is represented by a vector of the diagonal of the actual inertia tensor. That is to say, there are no off-diagonal elements in the inertia tensor. As Pieter mentioned, you need to think of the inertia tensor as the mass of the object. Once you do that, you can draw results from correspondence to linear equations. We all know that ...



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