# Tag Info

7

Calculate a vector from B to A, normalize it (divide by the vector's length), then multiply by the circle size: vx = A.x - B.x vy = A.y - B.y length = sqrt(vx*vx + vy*vy) C.x = vx / length * size + A.x C.y = vy / length * size + A.y For the angle you can use the atan2 function, if your language has it.

4

When people refer to an isometric perspective in the context of pixel art or video games, they are usually talking about a dimetric projection where the z-axis is vertical and the x and y axis go diagonal with a vertical:horizontal ratio of 1:2. The reason is that this is much easier to pixel than a "true" isometric projection: Alternatively there are ...

4

As I found out later here isometric in video games in game development it is better to have tiles with a 1/2 height/width ratio, which displays better and is nice for calculations. As I measured, having those ratios also means having a 127 degrees angle. Later, I found this answer on gamedev : What is the view perspective angle of most 2.5D isometric games ...

4

The sign of the dot-product of C with AB will be positive when the vector component of CD parallel to vector AB is in the direction AB, and negative when it is in the direction BA. The sign of the (z-component of the) cross-product of vector CD with vector AB will indicate which side of AB the agent is approaching from. Depending on your sign conventions, ...

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

3

Others have pointed out how you can use the sign of the dot product to broadly determine the angle between two arbitrary vectors (positive: < 90, zero: = 90, negative: > 90), but there's another useful geometric interpretation if at least one of the vectors is of length 1. If you have one unit vector U and one arbitrary vector V, you can interpret the ...

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

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

If I understand what you're asking, the vector CD is just a vector, not a ray, so only the direction matters, not location. However, AB is a line segment, not just a vector, so its location matters. Your tests have one 'if' test to make two cases, but I think you actually have four cases. Let's look at the diagram in AB's reference frame: If you can ...

2

to complete the answer: angle = atan2((C-A).y, (C-A).x) + PI/2;

2

If the resulting scalar is 0; then it means the 2 vectors are perpendicular to each other (angle difference 90 degrees) . If the resulting scalar > 0; then the angle difference between them is less than 90 degrees. If the resulting scale is < 0; then the 2 vectors are facing opposite directions ( or angle difference > 90 degrees). This can be useful in ...

2

A possible solution is to use the Dot Product. Of course, you need two vectors and not two angles, but I guess you're using them (otherwise I wouldn't explain how you're having 3D angles). Quoting Van Verth & Bishop from the book Essential Mathematics for Games & Interactive Applications, page 30-31: A more common use of the dot product is to ...

1

In 2D: The position of each block placed is {sin(theta),cos(theta)} = {x,y}. Hence at theta = 90°, the position will move only in the x-axis, by one block each time. The rotation of each block should be the same theta as well.

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

I think you could switch your cos with sin and vise versa if you're really against adding 90 in your function, but I think adding 90 is a perfectly viable solution. Once a function works, you shouldn't have to care what's inside of it.

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

atan2(y1-y2, x1-x2) or maybe atan2(-(y1-y2), x1-x2), depending on the coordinate system.

1

The white vector is the correct vector with the code you have. If you're only ever adding integers to your position, the movement is going to be at increments of 45 degrees. That's restricted to orthogonal and diagonal movement only. If you want free movement you should be normalizing the movement vector. Check to see if the libraries you're using have a ...

1

No conditions, you don't need normalised vectors, a single trig function: Vector2 pc = p - c; float crossp = pc.x * ray.direction.y - pc.y * ray.direction.x; float dotp = pc.x * ray.direction.x + pc.y * ray.direction.y; return Math.atan2(crossp, dotp); Here is the explanation. A fast summary: Cross product between two vectors is the same as sin(theta) * ...

1

We find the vector from c to p (p - c), and compute its angle with the x-axis. Then we subtract, and put it into the right range. theta2 = atan2(p_x - c_x, p_y - c_y) alpha = theta2-theta if (alpha > pi) alpha -= 2pi if (alpha <= -pi) alpha += 2pi This assumes that theta is in the range (-pi, pi], and atan2 gives its result in the range (-pi, pi] ...

1

Changing your camera, like the other fellows said, is probably the best, but if you still need the Camera to have perspective projection, you can use LookAt(), like this: 3dGameObject.transform.LookAt(camera.transform); Basically it makes your game object to rotate in order to look at something. Take a look at the documentation for more information on ...

1

First off, you probably want to switch your camera to orthographic, so that you don't get perspective distortion in the image. Then I wouldn't put the image on the ground like that, but rather a plane perpendicular to and linked to the camera. Then rather than rotating the player around, I'd be orienting the camera so that the player looks correct. The ...

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

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

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

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