Answer the question
In order to leave comments, you need to log in
How to find the coordinates of the points of a circle?
I need to make a ball of dots. I know that, in order to make just a circle of points, I need to use sine and cosine, actually https://jsfiddle.net/ouL2gkej/3/ here I did it. And how to draw a ball from points, but at the same time using two-dimensional space?
Answer the question
In order to leave comments, you need to log in
A simple option when looking at the ball at the level of the equator, in a parallel projection.
We take the center of the ball as a reference point, zero.
Two angles determine the position of a point on the surface of the ball relative to its center:
In the projection onto the plane (screen), the points of the ball will fall inside the circle of radius R
. The center will hit the center. The North Pole is at the top, the South Pole is at the bottom.
The height depends only on the latitude, everything is simple here: y = R * sin(lat)
Left-right from the central axis depends on both angles. The maximum possible distance from the axis depends on latitude R * cos(lat)
. And it can also decrease depending on the longitude: you need to multiply by cos(lng)
. Total turns outx = R * cos(lat) * cos(lng)
In addition, look in the code for how to correctly create elements inside SVG and set attributes for them. As well as the value of the viewBox so that (0, 0) is centered.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question