New answers tagged

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 * ...


0

Well, I generally use to ask this questions in interviews :) Although I don't know Swift but I can give you a general idea about to achieve this. You have to play with some trigonometry to get current direction vector according to your current angle. Here is the pseudo code. float speed = 0.01 void GameLoop() { // I don't know that how Vector2 works ...


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 ...


0

You can use setAngularVelocity(float omega) LIBGDX API for angularVelocity


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.


0

Well given 360-degree angles. Then a 360-degree rotation makes a full turn and as such is equivalent to 0-degrees or simply no rotation.


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 ...


0

Calculate the angle between the first and the second sprite using trigonometry, then modify the first sprite's angle according to the angle you got. To calculate the angle between two points, you need to have the distance in the x and y axis between them. x1 and y1 are the positions of the first sprite, x2 and y2 are for the second second sprite: x = x2 - ...


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 ...


0

I'm not entirely sure I get what you are asking, but here goes. Mathematically all rotations happen around the origin. So if you want to rotate something around a different point, you'd move it so that the difference from the origin is the same as it would be from that point and then moving it back by the same amount. Now I think what you are asking is how ...


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

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 ...


0

With Many thanks. Ship.TransformValue = -0.1 Ship.ShipAngle = Ship.TransformValue Dim LocalPosition As New Vector2(Ship.Position.X - cPosition.X, Ship.Position.Y - cPosition.Y) Dim TransormPosition As Vector2 = Vector2.Transform(LocalPosition, Matrix.CreateRotationZ(Ship.ShipAngle)) Ship.Position = cPosition + ...


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.


-1

translate your object with the same amount as the difference between the original rotating ankle and the new one, then rotate it. Let's assume, your object is in 2d space, is 50 pixels wide and high, and you want your new ankle to be in the top left corner, inszead kf in the middle, then you would wanto to translate the object wirh 25 pixels on the x, and ...


0

The thing you currently have is a transformation matrix Transfomation Matrices are way, to easily represent a the position, rotation and scale of an object in 3d or 2d scene, a 2d scene only needs a 3*3 matrix, a 3d one usually uses a 4*4, but 2d transformation can be represented in a 4*4 matrix too, but it just wastes space. The matrix is oriented like ...


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 ...


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 = ...


0

I recall an Amiga game Rotox based on that principle. To rotate easily look into Vector2.Transform(). You can feed it a matrix such as Rotation and translation matrices. point = Vector2.Transform(point, Matrix.CreateRotationZ(AngleToRotate); point += originPoint;


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 ...


0

There is simpler solution. That jittering happens because GUI is updated more frequently than the Update or LateUpdate. Just move the code related to raycasting from moving camera through cursor position into the OnGUI() function instead of Update() or LateUpdate(). Everything runs smoothly. Just remember that it may be called more than one time per frame so ...


0

This has been done before in a video tutorial for a "Horror Game". They label it 'True FPS'. Right now it sounds like the mouse movement is moving the camera and not the body. What you want to do is attach the Camera to a Socket on the Skeleton (if you want the camera to move with the animations as well). If not you can just position the camera where you ...


1

The name for this problem is Sensor Fusion, because we're taking readings from multiple sensors, each in some way incomplete or inaccurate, and combining them into a more reliable measure. In the past, I've had good results using a Complementary Filter for this task, which is effectively a weighted average. It's not state of the art, but it's ...



Top 50 recent answers are included