New answers tagged

-1

There's a function in scipy called "scipy.spatial.transform". You can look over in Rotation method which is trasform between euler_angles <-> R-matrix <-> quaternion.


1

There are a few ways to achieve that, here's what I found to be the easiest: By saving the location of your npc and the center of the car you can calculate the direction using a vector (x,y). In this image, the direction you want to drive in is (c-a, d-b). If you don't have the direction that the npc is driving at, you can calculate it by saving the ...


1

I assume you are storing map information in some kind of 2D array or something similar where you can easily check neighboring tile information. Any border tile will be missing at least 1 neighbor. You can then tell what direction based on which neighbors are missing, for example if you are missing neighbor tiles to the south and west you know it is the south-...


1

Some basics on convex hull tests for folks that might read this later: A convex hull is a volume defined by a number of planes (at least 4, but it could be much more). Testing to see which side of a plane a given point is on is trivial (computationally speaking), it's just a dot-product. Go look up "dot product" if you don't know what that is. Do it now. ...


0

You're looking for: offset_x = cos(angle) * radius offset_y = sin(angle) * radius This is the offset of the red point relative to the center of the circle. For angle = 0 this results in offset_x = radius, offset_y = 0, and for angle = pi/2 the result is offset_x = 0, offset_y = radius. This is merely a convention, and by swapping sin and cos, or negating ...


0

I’m assuming you mean you want the percentage of X between B and A, where at 0.0, X=B and at 1.0, X=A. The formula should be this: (pseudo code, I don’t know unity’s math functions) float r = dist(X, center); return (r - innerRadius) / (outerRadius - innerRadius); You can calculate innerRadius and outerRadius with the radius and center offsets. Your ...


0

Ok, I managed to solve this problem. I removed all the code posted above, made a new empty object (called rotationAxis) as the main object child and put the comet into the rotationAxis object 2f units from the center. After that, I just rotate the rotationAxis object with this code in Update(): transform.Rotate(0f, 0f, 3f, Space.Self);. Now, it's sticked to ...


1

Ah, the joy of creating resolution-responsive screen layouts in Unity. If I understand you correctly, your goal is to create an UI which always preserves its aspect ratio, but also fills as much of the screen as possible, letterboxing or pillarboxing as necessary. If that is the case: If your canvas itself has a Canvas Scaler component, remove it. Add a ...


0

For a square grid, there is a strategy which allows the player who is taking the next turn to always win. (it is actually mathematically proven that there is a winning strategy for the first player for any width and height except 1x1. But so far nobody found out what that strategy is, except for the special cases of a square board or a 2xn board). A losing ...


1

You do it backwards. You need a transformation that maps from the original image to the cuadrilateral. Well, actually, you need the inverse. In particular, you want a transformation matrix such that you multiply a position from the target canvas and it gives you a position in the original image. To derive that matrix, you define that image_position = M * ...


Top 50 recent answers are included