PDA

View Full Version : Maths...Myths...etcs...


Polimeno
02-07-2009, 08:43 PM
hey folks,
just starting some studies in math......so here i go :

1.
how to make a custom MAXscript to always build a "free form right triangle" ?? considering the facts/rules :

- Pythagorean Theorem (a+b = c)
http://www.math.com/school/subject3/images/S3U3L4DP8.gif

- has one angle equal to 90 degrees
http://www.math.com/school/subject3/images/S3U3L4DP1.gif

- all angles must be equal to 180

reference (http://www.math.com/school/subject3/lessons/S3U3L4GL.html)


my first test below just contains the first idea of "free form style"........

http://img.photobucket.com/albums/v205/RNThead_3D/pics/renato_MAXscript_test01_.gif

script here :


rollout test "triangle Maker"
(
group "Point 1"
(
spinner sp1_x "pos X:" fieldwidth:60 offset:[0,0] range:[-60,60,0] type:#integer
spinner sp1_y "pos Y:" fieldwidth:60 offset:[0,0] range:[-60,60,0] type:#integer
)

group "Point 2"
(
spinner sp2_x "pos X:" fieldwidth:60 offset:[0,0] range:[-60,60,0] type:#integer
spinner sp2_y "pos Y:" fieldwidth:60 offset:[0,0] range:[-60,60,0] type:#integer
)

group "Point 3"
(
spinner sp3_y "pos Y:" fieldwidth:60 offset:[0,0] range:[-60,60,0] type:#integer
)

group "settings"
(
button doMyLine "Build" width:120 offset:[0,0]
checkbutton showMe "Shy" width:120 offset:[0,0] highlightColor:green
)

fn GlobalVar =
(
global Pt1_xVal = sp1_x.value
global Pt1_yVal = sp1_y.value
global Pt2_xVal = sp2_x.value
global Pt2_yVal = sp2_y.value
global Pt3_yVal = sp3_y.value
)

fn GlobalPos =
(
global pos_Pt_1 = [(Pt1_xVal),(Pt1_yVal),0]
global pos_Pt_2 = [(Pt2_xVal),(Pt2_yVal),0]
global pos_Pt_3 = [0,(Pt3_yVal),0]
)

on doMyLine pressed do
(
try(
theOldLine = getNodeByName "Triangle" exact:on igonreCase:on
delete theOldLine
)catch()

GlobalVar()
GlobalPos()

theLine = splineshape name:"Triangle" steps:1 optimize:on adaptive:off wirecolor: red
addNewSpline theLine

Knot_1 = addKnot theLine 1 #corner #line pos_Pt_1
Knot_2 = addKnot theLine 1 #corner #line pos_Pt_2
Knot_3 = addKnot theLine 1 #corner #line pos_Pt_3

pT_1 = getKnotPoint theLine 1 1
pT_2 = getKnotPoint theLine 1 2
pT_3 = getKnotPoint theLine 1 3

Dist_1 = (distance pT_1 pT_2)
Dist_2 = (distance pT_2 pT_3)
Dist_3 = (distance pT_3 pT_1)

--------------------------------------------------

pT_1 = getKnotPoint theLine 1 1
pT_2 = getKnotPoint theLine 1 2
pT_3 = getKnotPoint theLine 1 3

Dist_1 = (distance pT_1 pT_2)
Dist_2 = (distance pT_2 pT_3)
Dist_3 = (distance pT_3 pT_1)

-- fn Rules_of_Triangles = ()

---------------------------------------------------

Close theLine 1
isClosed theLine 1

updateShape theLine
theLine
format " vert 1= %; dist 1= %; vert 2= %; dist 2= %; vert 3= %; dist 4= %; Line= %\n" pos_Pt_1 Dist_1 pos_Pt_2 Dist_2 pos_Pt_3 Dist_3 theLine
)

on showMe changed theState do
(
if TheState == on
then
(
showMe.text = "Show"
GlobalVar()
actionMan.executeAction 0 "40472" -- MAX Script: MAXScript Listener
format " 1_x= %; 1_y= %; 2_x= %; 2_y= %; 3_y= %\n" Pt1_xVal Pt1_yVal Pt2_xVal Pt2_yVal Pt3_yVal
format " vert 1= %; vert 2= %; vert 3= %; Line= %\n" pos_Pt_1 pos_Pt_2 pos_Pt_3 theLine
)
else
(
showMe.text = "Shy"
clearListener ()
)

)

)

createdialog test



somenone can help me to understand the meaning of those rules and how to apply them to my little script ?


other thing : how to auto-expose the index number of Knots ?
eg.
modPanel (spline subObject), vertex , display, checkbox Show Vertex numbers

thanks in advance

CGTalk Moderation
02-07-2009, 08:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.