A
A
Alexander Vasilenko2016-01-14 08:29:17
Java
Alexander Vasilenko, 2016-01-14 08:29:17

How to plot a sinusoid between two known coordinates (Java)?

Hello, friends.
Forgive me for completely forgetting math, but the issue needs to be resolved quickly, and I'm starting to dig in (a lot of work). I count on your help.
There are two coordinates (geographic):
a = (61.044039; 28.156276)
b = (42.689624; 23.402102)
There is a path between them in the form of a sinusoid in the period 2*Pi. We are moving along latitude. It is necessary to draw on the map 30 points on this sinusoid, equidistant from each other. How to do it using Java? More precisely, how to calculate these points (I have to add them to the collection when calculating), I know how to arrange them))))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2016-01-14
@fornit1917

Oh, I didn’t touch trigonometry for 8 years, but you can try ...
Further reasoning will be for the Cartesian coordinate system, in principle, it can probably be extended to width / longitude.
let (x1, y1) and (x2, y2) be given points.
The sinusoid must be sought in the form K*sin(x+a)+b, where K, a and b are some constants that must be found
We have:
K*sin(x1+a)+b = y1
K*sin(x2+a) +b = y2
It can be divided by K and further logic will not change, so for simplicity I will immediately consider K=1:
sin(x1+a)+b = y1
sin(x2+a)+b = y2
Location:
sin(x1 +a) - sinx(x2+a) = y2 - y1
According to the difference of sines formula:
2 * cos((x1+x2+2a)/2) * cos((x1-x2)/2) = y2 - y1
Replace x1 +x2+2a = t, and we get:
cos(t) = (y2 - y1) / (2*cos((x1-x2)/2))
On the right side is a number that we can calculate. We have the simplest trigonometric equation, from which it is easy to find t ( www.bymath.net/studyguide/tri/sec/tri16.htm). We know t - we know a. Substitute in sin(x1+a)+b = y1 and find b.
That's all, now we draw a graph f (x) = sin (x + a) + b
PS: it is worth noting that there may not be solutions, because not through any two points it is possible to draw a sinusoid with a period of 2pi
ЗЫ2: it is possible that I am wrong somewhere, I wrote the solution above with a swoop, as they say - on my knee.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question