Extra title cuz char limit:
Need help confirming if Ive successefully projected a sphere (onto the xy plane (z = 0)).
Code implementation does not make sense to me.
I am a programmer, so for my 2d, top-down, javascript game.
I wanted to add shadows to 2D objects on the scene. All objects are circles.
I tried representation the 2d circles as top down projections of spheres and shadows as projections of the spheres from a point light source.
I have made a 3D Desmos graph with my attempted algorithm. Linked here: www.desmos.com/3d/lmntbcqlmk
When I implement the algorithm into javascript I get weird artifacts that don't make sense. Artifacts attached.
The picture shows the 2D projection of the sphere as a rotated ellipse. The center of the shadow is the average position between the t_1 and b_1 variables from the desmos graph (top and bottom). The blue radius of the shadow is the distance between the t_1 and b_1 variables, halved. The green radius is just the object's radius.
Is anyone able to tell if my algorithm is the correct way to project a sphere onto the xy plane (z = 0). If so my code implementation is wrong.
I am able to link any resources asked for; Including my code implementation as well as variable for the Desmos graph.
Thank you.