Controlling rotation path in Unity3D - unity3d

On my top down 2.5D shooter game, I am usingQuaternion.LookRotation() and Quaternion.Lerp() to change the rotation of my player towards a click. The player rotates just fine, but I need more control over the rotation path. The issue here is that the LookRotation() always returns the shortest path to complete the rotation. I need the player to always rotate only in the X axis until its either +90 or -90 and then flip in the Y axis to the other side. It doesn't matter if the player rotate + or - 90 degrees over the X axis, but the idea is to always rotate in the X axis, before flipping from 1 frame to another, then rotating again in the X axis towards the click.
Here are some images illustrating the above. The "X" in red below, is where the "click" happened.

Related

Unity3D: Contrain movement to one axis at a time

I am making an isometric game in Unity. Im using a 3d cube as an agent for my 2d sprite. I have set up animations so that the sprite turn in the direction it is walking, however the cube is not walking in one axis at a time. Instead the cube moves in both the x and z axis, this messes up my animations. How am i suppose to contrain the cube to only walk one axis at a time so that the animations turn out correctly.
If your cube has a Rigidbody attached, you can check the axis you want to freeze under Rigidbody > Constraints > Freeze Rotation.

When rotating an image about its center, why do you need to add/subtract the centroid?

I'm learning about image processing in class, and it's all going quite fast so I'm having a bit of trouble wrapping my head around the different concepts. In rotation specifically, I understand that you need to multiply each of the pixel coordinates of an input image by the rotation matrix to get an output image. However, when you are rotating an image around its center, you need to do a translation to subtract the centroid, then rotate, then add the centroid back in. What is the logic behind this, how does it work?
In general, when you rotate an object, you rotate it about origin (0,0). But if you want to rotate the object about some other point, which in your case is centroid, you move the origin to that point by subtracting it. After rotation, when you want the output in the same coordinate system as you began with, you bring back the origin to its normal position by adding it back.
The images below demonstrate it to make better sense-
The object to rotate initially.
When you rotate it by 135 degrees anticlock. Output1
But if you want to rotate about centroid, move the origin there.
How it now looks -
Rotating the same 135 degrees anticlock now-
Getting back to the old coordinate system by adding back the centroid - Output2
Clearly the Output1 and Output2 are not same right, so subtracting and adding the centroid or not depends on about which point you want to rotate.

How to get x and y coordinates of touch in a 3d scene?

I have a plane, and a camera pointed at that plane. If i touch the plane, i would like to get the x and y coordinates of the touch.
I made a quick image to demonstrate what i want. Basically first the finger touches one place on the plane/screen, and the system prints it's x and y coordinates. Then it touches somewhere else and now it shows the coordinates of the other touch.

Unity - Matching Speed While Transistioning From Traveling on a Single Axis to Rotation Around a Circle

I am working on a simple project that consists of a ball with a rigid body being pushed along the x axis. The ball needs to transition 90 degrees and continue straight up.
I've created a box to serve as a pivot/rotation point and placed it exactly 5 units above the beginning of the 90 degree transition from and exactly 5 units away from the end of the transition. I've created two colliders that work as triggers; one at the beginning and one at the very end of the 90 degree transition.
So my ball will come zooming along on the x axis and hit the first trigger. When it does I reset the ball's velocity to zero and parent the ball to the box serving as a pivot/rotation point. I've then applied angular velocity to the box so that the ball will rotate exactly 5 units around the pivot point. When the ball hits the second collider at the end of the transition it is un-parented and velocity is reapplied so the ball can continue straight up.
So here is the question; if the ball is 5 units away from the pivot point, the distance traveled for the 90 degree transition would be something like : 5 * 2 = the circles diameter * PI = 31.4 units distance around the circle / 4 = 7.84 game units to travel for the entire 90 degree transition.
So how do I match the velocity the ball had while traveling solely on the x axis so that it has the same speed while transitioning using the pivot point rigid body's moveRotation function around a circular axis?
If I have a velocity vector of (-10, 0, 0) when I hit the first trigger how do I calculate what to feed into the moveRotation function so that a the ball, rotating 5 units away from the pivot point, is still traveling at 10 units a second?
Taking the original velocity (-10, 0, 0) and multiplying by the distance needed to travel for the 90 degree transition(7.85 units) looks really close but I can figure out how to check it.

Detecting the direction of the accelerometer movement on the y axis

I currently detect movement on the y axis. How does one calculate the direction it moved on the axis?
I get the same values when moving up or down.
Is the Gyro needed for this?
Do remember that the accelerometer will reflect the force of gravity. So movement up and down will generally be reflected as 9.81 m/s2 plus or minus the actual acceleration of the device relative to the Earth.