r/Maxscript • • Feb 28 '19

How to generate vectors?

I want to create splines that start at [0,0,0] and then move out radially in all directions, how could I iterate/create that 2nd knot position?
If I created a geosphere and then sent the vert positions to an array then I would have vectors that are suitable, but I'm not sure how to nicely generate them from scratch.

1 Upvotes

4 comments sorted by

2

u/Swordslayer Mar 01 '19 edited Apr 14 '19

If I created a geosphere and then sent the vert positions to an array then I would have vectors that are suitable

Nothing prevents you from doing just that (distributing points on sphere is hard), you don't have to create a scene node for that to work:

(
    local geoMesh = (createInstance GeoSphere radius:1 segs:9).mesh
    local vectors = meshop.getVerts geoMesh #all
    delete geoMesh
)

If you need an exact number of vectors, see my Fibonacci Sphere.

1

u/[deleted] Mar 01 '19

Alright thanks for the example too.
That vertCount concept seems scary to purposefully implement, currently I'd stumble upon exposing that spinner rather than design it.
I've got a 3D graph app with lots of formulas that I'd like to translate into Max, so seeing examples like that (as a plugin no less) is really going to help me along the way.

2

u/Swordslayer Mar 01 '19

You know the drill: look it up at wikipedia, translate formulas from there to code and call it a day. If I actually knew what the 'a' and 'b' stand for, I'd have chosen better names for the variables :)

1

u/[deleted] Mar 01 '19

I made an array of unit vectors that iterate over 1 axis. Then I looped over that array rotating the members by 45 degree increments using "rotateZMatrix i"
It's not optimal because I make one array and then do something with it as a second step, also my creation of the initial array is probably ugly too.