# Best way to manipulate Vector3's

## Recommended Posts

http://www.babylonjs-playground.com/#JVMS0#17

I am getting to the point of generating limbs.  the way I want to do it is not have to worry about the angle of the trees limb when generating the circle spline for its ribbon.  So I was wondering is there a way to make a path array for example a circle, and before you use that array in a ribbon rotate or transpose that path.  Any time I have tried to set the vector3 later like when iterating through an array of the points it seems to set the value to NaN even though the calculations are spot on and worked once i implemented them into the creation of the pathArray.

so yea, got a circle spline how to I translate it in space?

##### Share on other sites

Not sure whether this is the best way or even if it is an applicable way for your project but will explain what I did when I wanted to form a ribbon using a circular spline in a particular direction.

I wanted to create a tree ( a forest type tree) that forked at the end of the branches. The direction of the fork would be calculated and the ribbon created in that direction. The PG is http://www.babylonjs-playground.com/#QNVMR#2

I have created a simplified version http://www.babylonjs-playground.com/#QNVMR#3  that just generates a branch

but is still more than needed for an ordinary cylinder - you do not need 20 path points (d_slices) - start and end would do.

a_slices is the number of sides for the polygon that approximates the circle.

First of all I created a new coordinate system of axes using the branch direction as a generator. This gives a system  sys.x, sys.y, sys.z  where sys.y will be the direction for the new branch. See function lines 13 to 24

The branch is created using the position to start the branch (start_at), length of the branch (length) , the radius of the branch (radius)  and the coordinate system (sys) to use when creating the ribbon

Hope this gives you some ideas.

##### Share on other sites

Yea I think this is what I am looking for.  Effectively I just need to make the ability to create the spline aligned to an independent y axis determined by a point and a vector angle which I think you are doing.

i already have the circle subdivision figured out through a simple pie division calculation so that's not an issue.  I'll take a look at your example and I'm sure it will help.

im also gonna have to figure out how to connect the branches and the trunk into a single clean mesh with no weird gaps.

##### Share on other sites

the way I am looking at it is I am generating circles, and stacking them then drawing the ribbon, I think you are drawing paths that run along the outside of where my circles would be so its like we are constructing it differently.  How would I just pass a vector3 to my path creation method and have it make the circles to that axis.  So like if I want a flat circle i would pass a vector of (0,1,0) and the up vector of the center point of my circles would be perpendicular to that vector at what ever coordinate point.

##### Share on other sites

Is this more what you are after http://www.babylonjs-playground.com/#QNVMR#6

##### Share on other sites

Yea sir, perfect. . Sometimes you guys are amazingly helpful!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.