Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting a point on the edge of a sphere

Tags:

math

3d

So coming from a flash background I have an OK understanding of some simple 2D trig. In 2d with I circle, I know the math to place an item on the edge given an angle and a radius using.

x = cos(a) * r; y = sin(a) * r; 

Now if i have a point in 3d space, i know the radius of my sphere, i know the angle i want to position it around the z axis and the angle i want to position it around, say, the y axis. What is the math to find the x, y and z coordinates in my 3d space (assume that my origin is 0,0,0)? I would think i could borrow the Math from the circle trig but i can't seem to find a solution.

like image 638
James Hay Avatar asked Jun 09 '09 12:06

James Hay


People also ask

How do you find a point on the surface of a sphere?

The general equation of a sphere is: (x - a)² + (y - b)² + (z - c)² = r², where (a, b, c) represents the center of the sphere, r represents the radius, and x, y, and z are the coordinates of the points on the surface of the sphere.

Do 4 points define a sphere?

A sphere is uniquely determined by four points that are not coplanar. More generally, a sphere is uniquely determined by four conditions such as passing through a point, being tangent to a plane, etc. This property is analogous to the property that three non-collinear points determine a unique circle in a plane.


1 Answers

Your position in 3d is given by two angles (+ radius, which in your case is constant)

x = r * cos(s) * sin(t) y = r * sin(s) * sin(t) z = r * cos(t) 

here, s is the angle around the z-axis, and t is the height angle, measured 'down' from the z-axis.

The picture below shows what the angles represent, s=theta in the range 0 to 2*PI in the xy-plane, and t=phi in the range 0 to PI.

enter image description here

like image 112
second Avatar answered Sep 17 '22 13:09

second