Create cylinders from two points and given radius in maxscript

Create cylinders from two points and given radius in maxscript

Anonymous
Not applicable
1,803 Views
4 Replies
Message 1 of 5

Create cylinders from two points and given radius in maxscript

Anonymous
Not applicable

How two creat cylinders from two points and given radius in 3dsmax maxscript? Thank you!

0 Likes
Accepted solutions (1)
1,804 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Sorry, I actually only want to know how to proper rotate the cylinder after I create it and move it to point1. I was using the following code to calculate the eulerAngle but apparently the result is a wrong rotating direction.

 

fn drawCylinderBetweenTwoPoints pt1 pt2=
(
	vec=pt2-pt1
	he=sqrt((pt1[1]-pt2[1])^2+(pt1[2]-pt2[2])^2+(pt1[3]-pt2[3])^2)
	cy=cylinder() 
    cy.pos=pt1
    cy.radius=2
    cy.height=he
	

    r = sqrt(vec[1]*vec[1] + vec[2]*vec[2] + vec[3]*vec[3])
    t = atan(vec[2]/vec[1])
    p = acos(vec[3]/r)
	
	euler12=eulerAngles r t p
    cy.rotation=euler12 
	
	return cy
)

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

New problem, in some case, the cylinder would perfectly created, but in other cases, there is a problem that is related to Quaternion. The actual rotating angle required does not equal to the angle of two vectors

 

 

0 Likes
Message 4 of 5

Swordslayer
Advisor
Advisor
Accepted solution
Message 5 of 5

Anonymous
Not applicable

Wow that is perfect ok, how could you know that.

0 Likes