Finding distance to a plane in a rotating system - math

I have this pre-school-level problem, I just don't know what direction to start, i'm pretty lame at math. Let me simplify my question through an example: We have a flying helicopter with a distance measuring equipment at the bottom, it is looking down. The ground is flat, the chopper can tilt forward and back and left or right. (can do both axes simultaneously) If the helicopter is completely in level my distance measure shows the altitude of the heli above the ground.
How to calculate the altitude with a given theta and phi tilt angles of the helicopter?
I have this feeling, it can be done by using simple 2D trigonometry, instead of 3D vector algebra to calculate line-plane intersections.
Thanks in advance!

I guess it would be:
altitude = D*cos(theta)*cos(phi)
Where D is the distance to the ground as measured from the helicopter?

Related

Quaternion issues

I'm working with a MPU9250 to control a 3D position. I have an object that can rotate in 3 axis ( Roll, Pitch and Yaw) but I found some problems.
Initially I tried to calculate Euler Angles from Quaternions, but I discover that Euler Angles have 2 discontinuity in +/- 90 degrees, and so if I rotate the MPU for 365 deg it gives me wrong values like it's shifting while rotating.
I read that there is the possibility to convert Quaternions to DCM (Direction Cosine Matrix) but I find this algorithm fills too much the Arduino processor for calculations.
The last possibility that comes to my mind is to control the position directly with Quaternions, so I have to "forecast" the arriving Quaternion to stop the rotation when the MPU will give me the same Quaternion.
If anyone knows how to implement this or any other way please let me know your suggestions.
Many thanks,
Luca

Can I use homography to project camera image points to the ground (2D plane)?

My problem is quite simple yet I struggle to solve it correctly.
I have a camera looking towards the ground and I know all the parameters of the shot. So, using some maths I was able to compute the 4 points defining the field of view of the camera (the coordinates on the ground of each image's corners).
Now, from the coordinates (x, y) of a pixel of the image, I would like to know its real coordinates projected on the ground.
I thought that homography was the way to go, but I read here and there that "homography maps a plane seen from a camera to the same plane seen from another" which is a slightly different problem.
What should I use, please?
Edit: Here is an example.
Given this image:
I know everything about the camera that took the picture (height, angles of view, orientation), so I could calculate the coordinates of the four corners forming its field of view on the ground, for example (in centimeters, relative to the camera position, clockwise from top-left): (-300, 500), (300, 500), (100, 50), (-100, 50).
Knowing that the coordinates on the image of the blade of grass are (1750, 480), how can I know its actual coordinates on the ground?
By "knowing everything" about the camera, do you mean you have the camera FOV, rotation and translation with respect to the ground plane? Then it's trivial, right?
Write the camera matrix K = [[f, 0, w/2],[0, f, h/2],[0, 0, 1]]. Let R and t be respectively the 3x3 rotation matrix and 3x1 translation from camera to ground. A point on the ray going through a given pixel p=[u, v, 1] has camera coordinates r = inv(K) * p. Express it in world coordinates as R * r + t, intersect with the ground plane and you are done.

Trigonometry: 3D rotation around center point

Yeah, yeah, I checked out the suggested questions/answers that were given to me but most involved quaternions, or had symbols in them that I don't even HAVE on my keyboard.
I failed at high school trig, and while I understand the basic concepts of sin and cos in 2D space, I'm at a loss when throwing in a third plane to deal with.
Basically, I have these things: centerpoint, distance, and angles for each of the three axes. Given that information, I want to calculate the point that is -distance- away from the center point, at the specified angles.
I'm not sure I'm explaining this correctly. My intent is to get what amounts to electrons orbiting around a nucleus, if anyone happens to know how to do that. I am working with Java, JRE 6, if there are any utility classes in there that can help.
I don't want just an answer, but also the how and why of the answer. If I'm going to learn something, i want to learn ABOUT it as well. I am not afraid to take a lesson in trigonometry, or how quaternions work, etc. I'm not looking for an entire course on the answer, but at least some basic understanding would be cool.
If you did this in 2D, you would have a point on a plane with certain x and y coordinates. The distance from the origin would be sqrt(x^2+y^2), and the angle atan(y/2).
If you were given angle phi and distance r you would compute x= r*cos(phi); y=r*sin(phi);
To do this in three dimensions you need two angles - angle in XY plane and angle relative to Z axis. Calling these phi and theta, you compute coordinates as
X = r*cos(phi)*sin(theta);
Y = r*sin(phi)*sin(theta);
Z = r*cos(theta);
When I have a chance I will make a sketch to show how that works.

Need equations for a parametric parabola + the angle of the tangent at any given time

This may be ridiculously obvious, but math wasn't my strong suit in school. I've been banging my head against the wall long enough that I finally figured I'd ask.
I'm trying to animate a sprite moving along a 2D parabolic path, from point A to point B. Both points are at the same y-coordinate. The desired height of the parabola from the starting/ending y-coordinate is also given (or, if you prefer, a desired velocity). Currently in my code I have a timer firing at a high frequency. I would like to calculate the new location of the ball based on the amount of time that has passed. So a parametric parabola equation should work nicely.
I found this answer from GameDev adequate, until my requirements grew (although I'm not sure its really a parabolic path... I can't follow the derivation of the final equations there provided). Now I would like to squish/stretch the sprite at different points along the parabolic path. But to get the effect to work right, I'll need to rotate the sprite so that it's primary axis is tangential to the path. So I need to be able to derive the angle of the tangent at any given location/time.
I can find all sorts of equations for each of these requirements (parametric parabola, tangent at a point, etc.), but I just can't figure out how to unify them all. Could someone with more math skills help a fellow coder out and provide a set of equations that will work? Thanks ever so much in advance.
What you are missing is this:
Slope = TAN(angle) // in radians
What is the slope? It is how much up/down you move per how much across you move ( dy/dx on some other answers ). For you it is actually (dy/dt)/(dx/dt) since both x and y are functions of time.
So for a trajectory x(t)=Vx*t and y(t)=Vy*t-1/2*g*t^2 the slope is Slope=(Vy-g*t)/Vx where Vx is the initial horizontal velocity, and Vy the initial vertical velocity. g is the gravity (vertical acceleration down). So your rotation in degrees shall be
angle = ATAN( (Vy-g*t)/Vx ) * 180/PI
Basically the slope is equal to the ratio of vertical velocity to horizontal velocity.
Let X be the distance from A to B, Y the desired height of the parabola, V the horizontal speed.
x = Vt
y = Y - (4Y/X^2) (X/2-Vt)^2
tangent dy/dx = (8Y/X^2) (X/2-Vt)

GIS Draw a parabola flight path in kml for google earth

I have to display flight paths on google earth and (still I got the exact flight plan path) want to show in a parabola way (markting side). From the taking off to the landing points.
Basically I'm looking for the math formula to calculate latlng point with altitudes to display the parabola path.
I see how to do the parabolic view with the altitude parameter. But there is less easy, how to get points on a path from two cordinates (start; end).
Thank you !
Maybe I'm wrong about this, but if I remember my physics right, and if the distance between the two points is relatively small compared to the earth's radius, aside from altitude, the path will just follow a great circle.
If you write the coordinates as parametric equations as a function of time, you'd get:
gamma = v_horz/R * t
altitude = g * t * (T0 - t) / 2
(where T0 = 2*v_vert/g = flight time, R = earth radius, g = earth's gravity)
(vertical velocity = derivative of altitude = g/2*T0 - gt = v_vert - gt
where gamma = the angle along the great circle arc followed by the projectile. You know the beginning and endpoints, so you can use spherical trigonometry to figure out the arc distace G0 between start and endpoints. G0 = gamma at time T0 (when projectile lands). This tells you what omega_horz must be (= G0*R / T0).
You can then use spherical trigonometry again to figure out the lat/longitude at any point along the great circle. (use similar triangles -- it's too late in the day for my brain to work through the math properly, sorry)
assumptions:
A.
distance between start/end points is small compared to earth's radius
the flight in question is a ballistic trajectory (some mass M going up and down under the force of gravity alone, no thrust or lift)
we're talking about the planet Earth so you can make certain assumptions for the radius and the force of gravity g
ignore air resistance (good luck in real life)
OR
B.
this is for marketing types so you just want something that looks parabolic, so just use the assumptions in A anyway
EDIT: See also these wikipedia articles on projectile trajectories and great circle distance.

Resources