Notifications
Clear all

[Closed] Clone nodes between two points relative to spline

you don’t have to create a guide (copy) spline. i make it just for reference and don’t use in calculation…

the simple calculation of spline normal is:

get three points on the spline and use them as two vectors.

cross product of them give you a normal

the problem: what if the points are inline?

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

You mean when we have straight line and knots have same X_pos or Y_pos or Z_pos?

I just thinking. First method works in all cases.Right?
What if we create temporary TriMesh based on calculated points and then use vertex normals?

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

it’s almost how max does do it. and we can see results (path constraint controller, spline IK)

there is some simple trick… you can create that guide spline and temporary use it as path constraint… after that snapshot nodes, and delete the spline…

let me make some snippet

(@gazybara)
Joined: 11 months ago

Posts: 0

Ok.
You think that is a faster way then TriMesh? The only advantage that I see using mesh is preview of surface. Then I will know for sure if transform of cutting objects is correct. Nothing more.
Anyway you knows what is the best solution.

something like this:

fn scatterWithSplinePattern2 startNode endNode spline steps:10 = 
(
	fn matrixFrom2Vectors v1 v2 pos:[0,0,0] = 
	(
		front = normalize v1
		side = normalize (cross (normalize v2) front)
		up = normalize (cross front side)
		matrix3 front side up pos
	)
	
	s = getknotpoint spline 1 1
	e = getknotpoint spline 1 (numknots spline 1)
	
	stm = spline.transform
	
	tm0 = matrixFrom2Vectors (e - s) spline.dir pos:s
	tm1 = matrixFrom2Vectors (endNode.pos - startNode.pos) startNode.dir pos:startNode.pos 
	
	d0 = distance s e
	d1 = distance startNode endNode

	dtm = stm * inverse tm0 * (prescale tm1 [d1/d0,1,1])
	ps = copy spline name:"ps" transform:dtm wirecolor:green 
	
	pn = copy startNode name:"pn" wirecolor:red
	p = pn.position.controller = path_constraint path:ps constantVelocity:on --follow:on

	animate on at time 100
	(
		pn.rotation.controller.value = endNode.rotation.controller.value
		pn.scale.controller.value = endNode.scale.controller.value
	)
	for t=0. to 100 by 100./steps do at time t
	(
		snapshot pn
	)
	--delete #(pn, ps)

	pn
)
delete objects
animationrange = interval 0 100
slidertime = 0
(
	seed 0
	sp = converttosplineshape (helix radius1:(random 5 20) radius2:(random 5 20) turns:(random 0.3 2.0) wirecolor:green)
	tm0 = translate (rotate (scalematrix [1,1,1]) (eulerangles (random -180 180) (random -180 180) (random -180 180))) (random -[40,40,40] [40,40,40]) 
	tm1 = translate (rotate (scalematrix (random [0.5,0.5,0.5] [4,4,4])) (eulerangles (random -180 180) (random -180 180) (random -180 180))) (random -[40,40,40] [40,40,40]) 
	p0 = point name:"p0" size:5 transform:tm0 axistripod:off cross:on box:on wirecolor:yellow
	p1 = point name:"p1" size:5 transform:tm1 axistripod:off cross:on box:on wirecolor:orange

	with redraw off (scatterWithSplinePattern2 p0 p1 sp)
)

Denis this looks cool!
But seems that some points are skewed looking in top view.
Anyway I’ll try to study your code and customize to my needs.
I do not want to bother you anymore and waste your time.
Thank you very much for this very useful snippets.

sure… because i show not complete solution
to make them right you have to do interpolation in objects local space (not in world). how to do it? use list controllers for rotation and scale.

I knew it. You always do that. Ok thanks

Page 2 / 2