Tag Info

Hot answers tagged

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


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


3

You get the path the same way you'd move the object when you shoot it. Just have a tight loop that simulates the movement of the object and keep track of the position every so often. Now you have a list of positions, if you draw a dot at each position, you have a dotted line the represents the path of the object if it were to be shot from that angle.


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

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

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


2

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.


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

You wil want to subtract the touch with the ref point: //180 is inversed? 180 is when touch is on the right side... let dy = (touch.y - refPoint.y) //opposite let dx = (touch.x - refPoint.x) //adjacent This results in the (dx, dy) vector being from the refPoint to the touch point (as you would expect).


2

if (Math.abs( angle) > mindelta ) transform.LookAt (currCustom); I think it depends on floating point math errors, I suggest to define a min angle (mindelta in my code example) inside wich, the turret doesn't move


2

You're not taking into account the inverted Y axis in comparison to the normal X axis in most (maybe all?) programming languages. The top left corner of the screen is (0, 0), and is positive in the right and down directions. So if the bottom middle of your screen is, for example, (300, 400), and you click at (0, 400), then your triangle will be a first ...


2

Byte56's answer is very good, especially for the example image given where simulating the movement of each "ball" in the line will work well. I'll give you an alternative idea however which might work better, or might be easier to implement if you are trying to work with a dashed line (with or without animation), something like -- -- -- -- Calculate the ...


1

JSON Philipp makes a good point about JSON. It is human readable and makes debugging network code easy. If you have no experience in programming network code, this would be the way to go. Yes, there is a lot of overhead by using JSON, but for small to medium data transfers, it should be more than enough. And like Alexandre Vaillancourt said, you can always ...


1

Your drawings seem inconclusive with respect to axis names and signs. Just going by the first illustration, you could say approximately: _playerSpeedY = 2 _playerSpeedX = -1 // going to the left, negative! radians = atan2(_playerSpeedY, _playerSpeedX) degrees = radians * 57.29577951 I get radians = 2.0344439357957027 and degrees = 116.56505117080718 ...


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

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



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