Tag Info

Hot answers tagged

42

Radians are used in math because They measure arc-length on the circle, i.e. an arc of angle theta on a circle of radius r is just r * theta (as opposed to pi/180 * r * theta). When trig functions are defined in terms of radians, they obey simpler relationships between each other, such as cosine being the derivative of sine, or sin(x) ~= x for small x. If ...


3

Nathan's answer is very concrete. I'd like to supply a more general view: The most complex mathematical concept that is natively implemented in most processing units are floating point numbers as models for the field of real numbers ℝ. Visual geometriy is based on the three dimensional real vector space ℝ³. Coordinates are real numbers. Geometric quantities ...


2

Basically you will want to do something like this: deltaX = event.x - playerX deltaY = event.y - playerY normDeltaX = deltaX / math.sqrt(math.pow(deltaX,2) + math.pow(deltaY,2)) normDeltaY = deltaY / math.sqrt(math.pow(deltaX,2) + math.pow(deltaY,2)) ... bullet:setLinearVelocity( normDeltaX * speed, normDeltaY * speed )


2

It looks like your code to mirror the bullet's angle just flips the sign of the angle. This works great for reflecting an angle about the x-axis. 45 degrees becomes -45 degrees, etc. Now imagine reflecting off a wall that itself has an angle of 90 degrees. In this case, 85 degrees is reflected to 95 degrees; 45 degrees becomes 135 degrees, etc. Basically ...


2

The Red is: atan2(vectorA.y - vectorB.y, vectorA.x - vectorB.x) The Green is: atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x) The Blue which I think is what you are looking for: atan2(vectorA.y, vectorA.x) - atan2(vectorB.y, vectorB.x) You can use abs() if you want the absolute value like I think you do. Sometimes you will get a value that is ...


1

A solution that would work in all cases would be inverse kinematics. You may want to look it up, but that is quite a complex topic. Here is a general solution for your special problem: I don't really understand how the TopDondur and Berrels are related (or even what TopDondur is supposed to be) so I will for sake of simplicity assume only on "character". ...


1

This depends on your camera. So if the camera is directly facing the object, you can do this. The surface normal is lets say (x,y,z). z meaning the depth. Then just make z = 0, as if you are projecting it in to plane. Then angle is simply atan2(y,x). This is for the simplest case though. IF the camera is not aligned with the object then you have to figure ...


1

If you know which direction the characters are facing, you calculate the dot product of those directions. If the characters only move on the ground plane it is pretty staightforward to decide which side are you on. If the dot product is 0 then you face exactly the side of the opponent. Then you check for some interval against zero and decide if you are on ...


1

For FPS cameras, there is no technical reason why the pitch needs to be smaller than +/- 90 degrees; the reasons for limiting it are purely gameplay-related, and it's obvious if you've encountered it. When you are looking straight up or down, attempting to look left or right will not move your reticle with respect to the game world, instead you simply ...


1

I don't think there's a standard value. Some games let you go all the way to 90 degrees; some cut you off at somewhere around 85 degrees, I'd guess. I don't think the precise value is a big deal. Regarding the point about Euler angles, gimbal lock, etc. - there's actually no particular reason to limit the pitch to strictly less than 90 degrees, aside from ...


1

As it says: // Angle adjustment to make 0 up to match how our sprite was drawn. var angleAdjustment = -90; Likely that means the sprite was created with the plane facing right. This adjusts it to face "up". The angle doesn't have any thing to do with the coordinates system. Remember that you can always use the coordinate system you're familiar with and ...


1

Instead of an approach that relies heavily on trig (ie. your Atan2) as a means to solve the problem, 3d lends itself to a more linear algebra approach. float v1ComponentAlongD = Vector3.Dot(v1, d); // look ma, no angles Check out the last two paragraphs in Shawns blog here: http://blogs.msdn.com/b/shawnhar/archive/2010/02/12/doing-math-in-2d-vs-3d.aspx ...


1

While I use radians too, for all the reasons specified, there's at least one good reason why degrees are preferred: Precision and accumulation of errors. Rotating through a full circle 1 degree at a time is exact. Rotating through a full circle 2PI/360 radians at a time is not. Performing a 90 degree rotation 4 times on a pixel grid gets you back to ...



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