Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Uniformly distribute points around a 3d sphere

Author
Message
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 15th Jan 2022 00:35
Hello fellow adventurers c",)
How can i uniformly distribute (ex. 100) points around a 3d sphere in Agk?.
Been stuck on this for days, if you could shed some lights on this
for me that would just be terrific. I am lost in a jungle of Sin, Cos, Acos ex.
i have found so many snippets, tips and approaches but sadly non for Agk.
Can anybody please share a snippet with me, or some example to get this result.
"ask a question and be a fool for 1 minute..."

The author of this post has marked a post as an answer.

Go to answer

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 15th Jan 2022 02:43 Edited at: 15th Jan 2022 02:44
around? latitude? longitude?

if you just want to wrap them round the equator then a simple circle routine will do it

cos for the x, sin for the y, set the radius to half the sphere radius

px# = 0 + radius# * cos(angle#)
pz# = 0 + radius# * sin(angle#)





What your looking for??
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Attachments

Login to view attachments
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 15th Jan 2022 03:26 Edited at: 15th Jan 2022 06:02
@PartTimeCoder
Wow, great example.
Great too see another solution to get them wraped around.
Thank you PartTimeCoder!

But sadly this is not what i am looking for. I want them more like a grid of evenly
spaced dots around a sphere. For this i have seen some examples using fibonacci sphere algorithm
and different calculations, way above my knowledge. But i can't get it working in agk.

ex:
https://stackoverflow.com/questions/9600801/evenly-distributing-n-points-on-a-sphere
https://www.youtube.com/watch?v=RkuBWEkBrZA

Have made some slow solutions where i first pack the sphere with dots all around. Then delete dots nearer then (1).
this leaving a grid of dots. But by doing this i have no control over object variable names or final amount.
So i need a steady way to create ex "corona viruses". Each with 100 dots around its body. equally spaced out.
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 15th Jan 2022 04:21 Edited at: 15th Jan 2022 05:04
Reposted.
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 15th Jan 2022 04:29 Edited at: 15th Jan 2022 05:32
Here is my code for getting there but its too messy and i can't get it working with multiple "virus objects".
I need a way to make ex.100 dots spread out evenly, over a sphere.







Ps. This is my first thread, new to writing on forum and all

Attachments

Login to view attachments
OriginalKronos
6
Years of Service
User Offline
Joined: 10th Nov 2017
Location:
Posted: 15th Jan 2022 14:45 Edited at: 16th Jan 2022 00:32
How about this for a non mathematical approach. Probably needs a bit more tweaking I suspect the "single" spheres on the top and bottom of main sphere are actually loads of spheres in the same location.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Jan 2022 16:45
What do you mean its too messy? From what I can tell, it looks like your dots are pretty evenly distributed around that sphere.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Jan 2022 21:07
What you could do is load the sphere into a memblock and use the vertex points
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 16th Jan 2022 00:02
Thank you so much again @PartTimerCoder, you are the best!
Just the way you set up the function - so helpful to see.
This will give me plenty to play around with

Love all the different patterns it gives when changing around a few of the numbers.
Just what i was looking for. Even if the elusive fibonacci sequence still is out there somewhere.
The "Great" white whale. Well, it will just have to roam around out there for someone to find.
This seaman is ready for shore leave. Best of luck to the next Captain Ahab
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Jan 2022 01:52 Edited at: 16th Jan 2022 02:09
first attempt at converting Fibonacci sphere (?)


which doesn't look like the "1000 samples" pic @ the source:


closer @ 10,000 samples (with instances)?


it looks (mostly) "uniform" now, at the right camera location?

anyway, feel free to pick this up

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 16th Jan 2022 03:32 Edited at: 16th Jan 2022 03:33
Yeah that's about the closest I got as well, not quite sure how its supposed to look though that example image is not much to go on .... is the sprial at the top and bottom supposed to be like that or a error in ma codez?



Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Attachments

Login to view attachments
RotaMafia
6
Years of Service
User Offline
Joined: 13th Oct 2017
Location: Portveien 2, Norway
Posted: 16th Jan 2022 04:44 Edited at: 16th Jan 2022 06:50
This post has been marked by the post author as the answer.
With legends miracles seem trivial.
Omg, VirtualNomad *jaw drops* thats just perfect !






Thank you @VirtualNomad

“I try all things, I achieve what I can.”
― Herman Melville, Moby-Dick or, the Whale
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Jan 2022 05:01
glad you got what you were looking for.

meanwhile, we've got a new toy

Login to post a reply

Server time is: 2024-04-20 12:51:03
Your offset time is: 2024-04-20 12:51:03