Created
February 19, 2016 20:20
-
-
Save JokerMartini/d58d084ec495a152c3aa to your computer and use it in GitHub Desktop.
Maxscript finds the center point of a mesh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn GetCenter pts = | |
( | |
local center = [0,0,0] | |
minPt = copy pts[1] | |
maxPt = copy pts[1] | |
for p in pts do | |
( | |
/* Find the min pt3 values */ | |
if p.x < minPt.x do minPt.x = p.x | |
if p.y < minPt.y do minPt.y = p.y | |
if p.z < minPt.z do minPt.z = p.z | |
/* Find the max pt3 values */ | |
if p.x > maxPt.x do maxPt.x = p.x | |
if p.y > maxPt.y do maxPt.y = p.y | |
if p.z > maxPt.z do maxPt.z = p.z | |
) | |
center = (minPt + maxPt) / 2.0 | |
return center | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment