Can you use percent % in maxscript? If not is there a substitude approach?

Can you use percent % in maxscript? If not is there a substitude approach?

Anonymous
Not applicable
688 Views
2 Replies
Message 1 of 3

Can you use percent % in maxscript? If not is there a substitude approach?

Anonymous
Not applicable

can you use percent % in maxscript? If not is there a substitude aproach?

I saw this question asked on the internet which matched my question.

"Is there any way to find out if a point is inside/intersecting a cylinder with a defined radius and height rotated in any direction?"

A response was given below that does not use maxscript but it uses % which I was hoping could point me in the right direction.  I dont think mascript lets you use them. I am not even sure what they are.
Would I need to them in order to use maxscript and mascript normals and vector math to solve my problem?
thanks


function isInCylinder(%pos, %radius, %height, %normal, %point)
{
%normal = vectorNormalize(%normal); // just in case
%dist = mAbs(vectorDot(%point, %normal) - vectorDot(%pos, %normal)); // perp. dist. from plane of bottom circle to point
%point2 = vectorAdd(%point, vectorScale(%normal, -%dist));
if(%dist > %height || vectorDist(%pos, %point2) > %radius)
return false;
return true;
}

0 Likes
Accepted solutions (1)
689 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Just some language that uses them to denote variables, in maxscript it would look like this:

 

fn isInCylinder pos radius height normal pt =
(
	local dist = abs(dot pt normal - dot pos normal)
	dist < height AND distance pos (pt - normal * dist) < radius
)

isInCylinder cyl.pos cyl.radius cyl.height cyl.dir pt.pos

 

0 Likes
Message 3 of 3

Anonymous
Not applicable
Awesome!! thank you
0 Likes