Haversine formula - math

My question is about Haversine formula as arcsin x = arctan x/(sqrt(1-x^2), therefore the formula should have atan x and not atan2 x when we convert the formula from arcsin to arctan.
θ = 2 arcsin(sqrt(a)) = 2 arctan(sqrt(a)/(sqrt(1-a)))
But in most of the previews answers has an extra 2 after atan.
Can anyone explain it to me please. Thanks

atan(x) is the same as atan2(x,1). atan2(y,x) is the angle of the point (x,y), while atan(y/x) is the angle of the line through the origin and (x,y).
The only inverse trigonometric function present as FPU on x86 CPU/FPUinstruction is FPATAN which implements atan2. Thus also asin(x) is implemented as atan2(x,sqrt(1-x*x)), acos(x) as atan2(sqrt(1-x*x),x).

Related

Understanding rotation matrices derivation

Reading a book - "Introduction to 3D Game Programming with Directx12 by Frank Luna", I did not understand how we got the rotation matrix from function
the rotation matrix is:
to get this matrix from this rule:
Very nice formula.
Assuming |n|=1, the term (n.v)n is the projection of v in the direction of n, that must be unchanged.
The term v - (n.v)n is the projection of v in the plane normal to n, thus multiplied by cos(theta).
The term n x v is the vector normal to the plane containing n and v, thus multiplied by sin(theta).
I found that cross product and projection can be represented as matrices
The geometry of rotation about a vector n.

Split a cubic Bézier curve at a point

This question and this question both show how to split a cubic Bézier curve at a particular parameterized value 0 ≤ t ≤ 1 along the curve, composing the original curve shape from two new segments. I need to split my Bézier curve at a point along the curve whose coordinate I know, but not the parameterized value t for the point.
For example, consider Adobe Illustrator, where the user can click on a curve to add a point into the path, without affecting the shape of the path.
Assuming I find the point on the curve closest to where the user clicks, how do I calculate the control points from this? Is there a formula to split a Bézier curve given a point on the curve?
Alternatively (and less desirably), given a point on the curve, is there a way to determine the parameterized value t corresponding to that point (other than using De Casteljau's algorithm in a binary search)?
My Bézier curve happens to only be in 2D, but a great answer would include the vector math needed to apply in arbitrary dimensions.
It is possible, and perhaps simpler, to determine the parametric value of a point on the curve without using De Casteljau's algorithm, but you will have to use heuristics to find a good starting value and similarly approximate the result.
One possible, and fairly simple way is to use Newton's method such that:
tn+1 = tn - ( bx(tn) - cx ) / bx'(tn)
Where bx(t) refers to the x component of some Bezier curve in polynomial form with the control points x0, x1, x2 and x3, bx'(t) is the first derivative and cx is a point on the curve such that:
cx = bx(t) | 0 < t < 1
the coefficients of bx(t) are:
A = -x0 + 3x1 - 3x2 + x3
B = 3x0 - 6x1 + 3x2
C = -3x0 + 3x1
D = x0
and:
bx(t) = At3 + Bt2 + Ct + D,
bx'(t) = 3At2 + 2Bt + C
Now finding a good starting value to plug into Newton's method is the tricky part. For most curves which do not contain loops or cusps, you can simply use the formula:
tn = ( cx - x0 ) / ( x3 - x0 ) | x0 < x1 < x2 < x3
Now you already have:
bx(tn) ≈ cx
So applying one or more iterations of Newton's method will give a better approximation of t for cx.
Note that the Newton Raphson algorithm has quadratic convergence. In most cases a good starting value will result in negligible improvement after two iterations, i.e. less than half a pixel.
Finally it's worth noting that cubic Bezier curves have exact solutions for finding extrema via finding roots of the first derivative. So curves which are problematic can simply be subdivided at their extrema to remove loops or cusps, then better results can be obtained by analyzing the resulting section in question. Subdividing cubics in this way will satisfy the above constraint.

Normalized Eigenvectors Maxima

I wa swondering if anyone knows of any function in Maxima to find the normalized eigen vectors of a 21x21 matrix?
I am using the function dgeev but I do not believe these eigenvectors are normalized.
I appreciate Any thoughts,
Ben
The eigenvectors computed by dgeev are indeed normalized to have Euclidean norm = 1. Keep in mind that to compute the norm of a complex vector (let's call it v), you want
sqrt (ctranspose (v) . v)
Here ctranspose is the conjugate transpose.
ueivectors normalizes the eigenvectors but apparently not the eignevlaues

how to find tangent at time t in natural cubic spline

I used Tim Lamber's algorithm to draw a natural spline cubic curve.
NatCubic class
NatCubic class compute the coefficients of the cubics (a b c d) of an array of points.
a + b*u + c*u^2 + d*u^3 0<=u <1
and Cubic class compute the points on the curve at time t in [0-1].
b in Cubic class is the derivatives at the knots at i
My question is: how to find the tangent at t >0 <1
Thank you!
PS :
for clarify my question, I search the tangent at time t, eg 0.5
to using pre-computed coeficients (abcd) of each control point.
This is to avoid calculating the point(t+1) to find the tangent by, y(i +1) - y(i-1)
sorry for my poor english.
you can see in this picture that I want to do
Sont know if I well understood your question.
(EDIT)
Slope = b + 2c*u + 3d*u^2
then for the tanget use
(y - yo) = m * (x - x0)
where y0 is your spline value at point x0
and m is the slope at x0

What exactly does delta mean in the gradient descent algorithm?

As on the picture:
Could someone help me understand what exactly what delta means in the gradient descent algorithm?
This is a partial derivative with respect to theta_0.
The term is a derivative with respect to the theta 0.
Mark theta as coordinate on X-axis (let it be A)
Find corresponding coordinate on Y-axis (let it be B) so the point belongs to the function J
Draw tangent line to that function at the point (A, B)
The derivative is the slope of this tangent line.
The derivative is used to control two aspects of the cost function (J function) minimization:
direction - sign of the slope tells you in which direction you should move along the X-axis in order to converge J
rate - magnitude of the slope tells you how fast you should move

Resources