Maths...Myths...etcs...

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2009   #1
Maths...Myths...etcs...

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)


- has one angle equal to 90 degrees



- all angles must be equal to 180

reference


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



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
__________________
Website
Twitter
Facebook
Google+

Last edited by Polimeno : 02 February 2009 at 06:24 AM.
 
Old 02 February 2009   #2
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:18 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.