2
votes

This is the idea: there is sphere with radius = 1, the center is at 0,0,0. Now, this sphere works as a sort of a scanner - when you touch any point of the sphere a line is drawn to the center of the sphere (0,0,0) from the point of touching (origin point). Each frame the point expands and turns into a ring, like a ripple, moving on the surface of the sphere.

It might be a bit hard to visualize at first, but it's not that much of a difficult concept, I actually got it sort of working. The only problem - it only works from a few origin points, not from all.

This is the code:

for(int i = 0; i <= 180; i++)
{
    origin = new Vector3(
                 2f * Mathf.Cos(i * (Mathf.PI / 180f)),
                 0f,
                 2f * Mathf.Sin(i * (Mathf.PI / 180f)));

    for (int x = 0; x <= 360; x++)
    {
        quat = Quaternion.AngleAxis(x, Vector3.left);
        Debug.DrawLine(quat * origin, direction_center, Color.red, 0.02f);
    }

    yield return new WaitForSeconds(0.01f);
}

Now, it only has one origin point and I'm aware of that, it's just that, rather than changing the origin point, I tried rotating the entire thing, which didn't work. Now, how would I go around actually defining the origin point (any point of a sphere surface) and have the ripple start from it?

Edit: I apologize for lack of information - to do this I'm using Unity, coding with C#. Aside from that, I'm not sure what other information should be required.

Edit 2: I made a simple sketch of the idea - I need to find not every, but a 360+ points in the red circle. The circle starts from point A and ends at the opposite side of the sphere. Each frame I need to know the location of each point in 3D space. In this sketch there is only the point B. How could I calculate the position of B, knowing that the radius of the sphere and the position of point A? This formula should be applicable to any point. enter image description here

One more example: enter image description here

Edit 3: I have somewhat solved this, but in a different way without getting the equations. Because of this I do not know whether to answer my own question with a work around or leave the question for the actual answer, because this might help somebody.

1
Looks like C# and ILnumerics maybe? If so, please tag.leppie
Yeah, it's C#, just tagged, sorry, my first time asking here ;3PhoenixBlack
@PhoenixBlack It would probably be useful to also tag with what you're using to visualize/any other packages present. The tag sphere doesn't really give a lot of info.dav_i
Edited in the post, sorry >w<PhoenixBlack
@PhoenixBlack No need to apologise. SO can take a bit of getting used to, but it pays off massively when you get it. Try to give the community as much information as possible, format code, explain the problem, etc., etc. Best of luck!dav_i

1 Answers

0
votes

Assuming point A is at (Ax, Ay, Az) and point B at (Bx, By, Bz), you can follow these procedures to compute the ripple circle (which is the intersection between the sphere and a plane)

1) compute distance r = |AB|, the distance between A and B.
2) The ripple circle is defined by the unitized normal vector vec(n), center C and radius R* as

vec(n) = unitVector(P,A)
R* = r * sqrt( 1- r^2/(4R^2) )
C = P + h * vec(n)

where P is the center of the sphere, and h = (2*R^2 - r^2)/(2R) and R is the radius of the sphere.

With the definition of the ripple circle, hopefully you can compute as many points on it as you want.