# [SOLVED] How do I project a 3D Sphere on a 2D canvas

Get help using Construct 2

### » Tue May 30, 2017 3:36 pm

Here I am, struggling with math that goes above my head.

Some days ago, I saw an animation of a sphere with white dots attached to it, rotating.
Example:

I thought that looked pretty neat and thought that it must be possible to recreate this in C2 with some simple math.
How wrong I was.

At some point reading through the article, I figured I still need to learn a lot to be able to understand this.
So I kinda gave up on understanding it.
But I didn't want to give up on at least having a finished version of it in C2, maybe even learning something in the process.

So I went ahead and more or less copied the code in the article ( + the source code provided in the article) into C2.
And of course it didn't work.

Now I know that to help me with this is quite the request, but maybe someone got some free time and motivation and is up for this challenge.

This is what I've gotten so far by simply copy&paste and that doesn't work at all.
Now, again, I am no math expert, by no means, I simply want to complete this to go to sleep happily.
Any feedback is hugely appreciated!
Last edited by randomly on Tue May 30, 2017 9:46 pm, edited 1 time in total.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

### » Tue May 30, 2017 6:24 pm

Here's you version tweaked to work:
https://www.dropbox.com/s/68gwhdp68n5na ... .capx?dl=1

And here's a few points of what had to change:
1. Angles in js are in radians and in C2 angles are in degrees. All this means is you replace pi with 180 in all the formulas.

2. Position information is being lost since x,y is being rotated and projected every frame. The solution for that is to store the original position in px,py,pz variables and set x,y,z from that. This is actually the biggest reason it didn't work.

Other than that there were some things you could simplify but it wasn't crucial.
B
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Tue May 30, 2017 9:46 pm

@R0J0hound you never let me down.
Actually, when I posted this, I hoped that you would answer.

Thanks so much!
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091