How do I calculate moon phase angle at any given coordinate? - math

I'm having a problem for a couple of days where I'm trying to accurately calculate the phase angle of the moon at any given Coordinates (lon,lat).If I know my current Coordinates, Moon and sun topocentric right ascension, declination, altitude and zenith Coordinates.
Given all of that data, how do I achieve that ? The result I'm looking for preferable in degrees where 0 degrees means the crescent moon pointing directly towards me, 180 degrees means the crescent moon pointing at the other direction and so on..
I have tried a formula where I measured the angle between the sun zenith and a certain coordinate in relation to the moon zenith, on paper this could work, the results were decent but not to the accuracy I'm looking for. Any help would be much appreciated.

Related

Calculate the direction vector and distance between two coordinates in latitude and longitude in short distance? RTK rover

I am trying to calculate the direction vector and distance between two points with a short distance in between (for example 1 meter). Normally I get those coordinates from two rovers in the RTK system with high accuracy.
So, what is the best and most accurate formula for this purpose as I went through too much mathematics and was confused about which to use?
Thanks

How can I get 1angle from 3 alsolute orentation sensors?

I try to get 1 angle (e.g. Dorsi Plantar Flextion Angle) from alsolute orentation sensors which output is (Quaternion, Euler angles, Rotation vector,Linear acceleration, Gravity, Heading).
Sensor is 'Bosch BNO055'
May be I would use Euler angles from 3 sensors.
What I want to ask is Is there a formula or process that calculate one angle from 3 Euler angles?
Thanks ahead.

Calculate bearing from lateral and longitudinal speeds

How can I calculate the bearing from an relative "origin" by lateral and longitudinal speeds?
For example if the lateral speed was 0 meters a second and the longitudinal speed is positive, that would mean the bearing would be 0 degrees of "origin" but if the longitudinal speed was negative that would indicate the bearing is 180 degrees of "origin". This scenario is simple. (I think, laughs at self).
Now lets make things interesting. The longitudinal speed is still positive, say 30.0 meters a second and my lateral speed is -0.05 meters a second. That would indicate my bearing would be angled ever so slightly "left of origin". But specifically what degree?
Is there a formula to calculate the bearing from two speeds?
Thanks!
After digging into the trigonometry trenches. I found a solution.
Given a lon/lat speeds create a 90 degree triangle. In this scenario the hypotenuse doesn't matter.
It boils down to (in python for folks)...
fraction = a / b # sides of the projection that form the 90 degree angle
if b < 0:
fraction = b / a
bearing = 360 - (90 + math.atan(fraction))
Using that bearing. If you have a distance you can project a point.

Direction of resultant vector

in this question- a motorboat is racing towards north at 25 km/hr and the water current in that region is 10 km/hr in a direction 60 degrees east of south. find the resultant velocity and direction of resultant velocity of the boat.
For getting the velocity i just used the cosin formula and got 22 km/hr approx but i cant seem to understand how to calculate the direction when the angle between the vectors is 120. it is easy when the angle is less that or equal to 90 when we just find tan theta where theta is the angle between the vectors. but how do we go about doing this?
The velocity is as actually a vector with a direction. If you sketch this you will have a vector addition (build a parallelogram) of The boats speed vector and the water flows speed vector. The directions of the vectors you can extract from the given direction. For example take north as (1,0) direction and draw an arrow in the correct length (speed).
v_boat = 25 * (1,0)
v_flow = 10 * ...
v_sum = v_boat + v_flow
v_sum_magnitude = magnitude of v_sum
For the background:
Velocity is working with the principle of superposition.

Find intersection and ETA

I have 2 coordinate points A,B and I want to know the formula to calculate the intersection point if that exist.
Let's say I have an airplane at Lat: 42.68543 Lon: 16.9880 moving at 196 deg with 430km/h and another one at Lat: 36.72348 Lon: 20.76236 moving at 269 deg with 670km/h
1) I want to calculate the intersection point (if exist)
2) If intersection exist I need to know the estimate time that each craft needs and the distance to the intersection point
Can you help me with a Java example on how can I find it?
If you have position vectors A=(xa,ya) and B=(xb,yb) and corresponding velocities Va and Vb, you are trying to solve A+s*Va=B+t*Vb. This is the solution for any coordinate system, but first you have to choose a coordinate system.
Let's solve it first for Euclidian space...
Write this out for each component x and y. You now have two simultaneous equations in two variables and can solve for both s and t. They will collide if s==t (or is 'close'). Watch out for divide-by-zero when Va and Vb are parallel, and numerical instabilities.
For a spherical solution, consider two points moving on the circumferences of circles, the equations are the same form although A and B will be angles and Va and Vb will be angular velocities. To get the circles, calculate Euclidian Va and Vb instantaneously at any time, this taken with the Euclidian A and B (assuming Earth is centred at 0) tell you what plane you're working in, project into this plane to get a 2D problem for each plane separately.

Resources