# Tag Info

40

You're trying to calculate the Torque. Torque depends on the applied force F, the point of application, and the center of mass of the object. 1) Center of Mass. Define the center of mass of the object. 2) Point of Application: Define the point at which the force acts on. 3) Moment Arm: The distance between the two points defined above. Point ...

27

Have you considered that it looks very odd for a person to standing perpendicular to a slope? You need to be upright to stay in balance. Some alternatives: Treat his feet as a separate object and rotate them to be parallel to the slope. (A raycast will find the angle's normal, as dnk described. The angle for the feet is that + 90°.) Fake it, by ...

18

What you are asking for is called Arcball rotation. Quaternions are the easy solution only if you understand how they work. You can achieve the same without quaternions however. Pre-requisites Do you know how to rotate objects in general? Let's say you have an object at the origin. Do you know how you rotate it (hint: multiply by some rotation matrix)? If ...

18

17

In short You only need to change T in your SQT form. Replace the translation vector v with v' = v-invscale(p-invrotate(p)) where v is the initial translation vector, p is the point around which you want the rotation to occur, and invrotate and invscale are the inverses of your rotation and scale. Quick demonstration Let p be the point around which you ...

15

The angle you need to rotate by is the the angle your velocity vector makes with the positive x-axis. This angle can be calculated using the inverse tan of the slope of the vector. In XNA, we use the Math.Atan2 function. Give the function the y coordinate and the x coordinate of the velocity vector (in that order). Atan2 will return an angle between +PI/2 ...

14

All of the canonical rotational formulas used to derive your rotation matrices are for rotation about the origin. If you would like instead to apply that rotation around a specific point, you must first offset the origin -- or, equivalently, move the object so the point you want to rotate about is at the origin. Consider the 2D case first, because it is ...

11

glm::quat myquaternion = glm::quat(glm::vec3(angle.x, angle.y, angle.z)); Where angle is a glm::vec3 containing pitch, yaw, roll respectively. PS. If in doubt, just go to the headers and look. The definition can be found in glm/gtc/quaternion.hpp: explicit tquat(tvec3<T> const & eulerAngles) { tvec3<T> c = glm::cos(eulerAngle * ...

11

The basic idea is to use a cross product to generate the extra orthogonal axes of your rotation matrix, based upon the axes that you already have. Matrix3x3 MakeMatrix( Vector3 X, Vector3 Y ) { // make sure that we actually have two unique vectors. assert( X != Y ); Matrix3x3 M; M.X = normalise( X ); M.Z = normalise( ...

11

You could just store the rotations in an array like you'd store your blocks, four for each block type, then just iterate over them. That way you don't have to deal with the mess you've described.

10

I'm not familiar with GLM, but in the absence of a function to directly convert from eular angles into quaternions, you can use the "rotation around an axis" functions (such as "angleAxis") to it yourself. Here's how (pseudocode): Quaternion QuatAroundX = Quaternion( Vector3(1.0,0.0,0.0), EulerAngle.x ); Quaternion QuatAroundY = Quaternion( Vector3(0.0,1.0,...

10

Well in the simplest sense you have something like this. y |\ | \ m | \ s o | \ p v |(a) \ e (y)e |angle\ e m | \ d e | \ n | \ t | \ |__________\ x movement (x) The speed is however fast the enemy is, and you can determine how much they ...

10

You'll want to get a vector based on your current velocity and heading. Then use that vector to increment your position. //first get the direction the entity is pointed direction.x = (float) Math.cos(Math.toRadians(rotation)); direction.y = (float) Math.sin(Math.toRadians(rotation)); if (direction.length() > 0) { direction = direction.normalise(); } /...

10

Well, you'll have to use a little bit of physics, but you don't need to simulate any physics. There are formulas for pendulum motion you can easily use to set the rotation of your pendulum. For small swings, the motion can be approximated with simple harmonic motion. The angular displacement at a specific time can be approximated with: This is most ...

9

The LookAt function does this for you. You may be using it improperly, or something is wrong with your steering if you're having problems with this. You can try it this way too: //find the vector pointing from our position to the target dir = (Target.position - transform.position).normalized; //create the rotation to look at the target rotation = ...

9

The secret is atan2: Vector2 exitPosition = whatever; Vector2 currentPosition = whatever; Vector2 direction = exitPosition - currentPosition; float angle = (float)Math.Atan2(direction.Y, direction.X); atan2 (MSDN) gives you the angle of a vector, with the positive X axis being at an angle of zero, and moving in the positive direction towards the positive ...

9

Given only a point and a direction there is no defined 'right' or 'left'. Imagine being a falling raindrop, which direction is right or left for you in that case? In order to calculate (or even define) a right or left you need two directions, typically forward and up. You seem to already have a forward direction, so you need to define a up direction. ...

9

There are 360 degrees (2π radians) in a circle. Divide that by the number of objects, and that tells you the correct angle between the objects, for even spacing. If you want to keep the objects the same distance apart no matter how many objects are in the circle, we need to calculate the distance out from the center at which points are that distance apart. ...

9

The simple solution is not to store the orientation of the object as angles around axes (X-, Y-, Z-axis), as for instance in euler angles. Store the orientation of the object as a matrix or a quaternion. This can cause gimbal lock, using euler angles: class Object { float m_angleAxisX; float m_angleAxisY; float m_angleAxisZ; }; No gimbal ...

8

Here is a way to rotate a Matrix (model) around a specific point : Vector3 pointToRotateAround = modelWorldTransform.Translation + modelWorldTransform.Down * modelHalfHeight; // modelHalfHeight is meant to represent distance from fbx origin to feet plane modelWorldTransform.Translation -= pointToRotateAbout; ...

8

Most APIs represent the Sprite's origin in local space, not in world space. This is supported by libgdx's documentation which states: A Sprite also has an origin around which rotations and scaling are performed (that is, the origin is not modified by rotation and scaling). The origin is given relative to the bottom left corner of the Sprite, its position....

8

What you want to do is something called LERP. Stands for Linear Interpolation, and you can do with the follow: If you know how many seconds have passed, and what is the total, you might do the follow: u = total / passedTime u is your "progress" variable, on a LERP. So, as your start value is 0 and the final value is 360, we do the following: current = ...

8

Conceptually you've got it, just think of the rectangle as a helper for you to deal with position and collision detection of your image. To implement it you could use: mySprite.image = pygame.transform.rotate(Surface, angle) This will give you a rotated Surface (image), then you can use: mySprite.rect = mySprite.image.get_rect() To give you your new ...

8

I'm not sure of a good way to preface this, other than I hope it ties together nicely by the end. That said, let's dive in: A rotation and an orientation are different because the former describes a transformation, and the latter describes a state. A rotation is how an object gets into an orientation, and an orientation is the local rotated space of the ...

8

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

8

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

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

The straightforward approach is to find the extents of the unrotated bounding box apply the same rotation matrix to those extents as you did to the sprite (but on the CPU, so you may need to employ your own matrix math here) recompute the AABB of the rotated extents (which should be cheap since there are only four). It's possible to perform the operation ...

7

If you have three sprites (or if they have very specific relative positions, which almost never happens) there is a special point called the circumcentre which is at an equal distance of each sprite. However, this doesn't scale to more than 3 sprites and doesn't work if they are aligned. The best solution would probably be to compute the barycentre of all ...

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