MacMan
BattleForums Senior Member
- Joined
- May 17, 2003
- Messages
- 1,943
- Reaction score
- 1
So school is over and I'm not making programs for my TI-83+ anymore. I got the urge to do some math, and I figured I could work it into one of my game's map editors. (This is my first script in this language, so there's tons of redundant things to be sure it works right.) Basically what it does is graph curves (curves are the only thing hard to make in this editor) as a sequence of lines. The cool part is that you can rotate polygons or sin/cos functions any number of degrees. Think about it, a goddamn sine wave at a 66° slant with its coordinates graphed on the plane. How fucking awesome is that!!
Anyway, this was only done in applescript, not xtools, so I can't give you guys a port. Just thought you might want to see some simple mac programming. See if you can follow the math... muhahahah!
(I know, I know, there are things line sin (2pi) as mutipliers with no variables, but that's just me being cautious.)
(source continued in next post)
try
set iniAsk to display better dialog ¬
"" fields ¬
{{kindopup menu, name:"Figure type:", menu items:{"Regular polygon", "Sine wave", "Cosine wave"}, value:"Regular polygon"}} ¬
buttons {"Enter", "Quit"} default button 1
set figType to value of item 1 of fields returned of iniAsk
if button returned of iniAsk is "Quit" then
quit
end if
if value of item 1 of fields returned of iniAsk is "Regular polygon" then
set myResult to display better dialog ¬
"Regular polygon:" fields ¬
{{kind:text field, name:"Number of segments:", value:""}, ¬
{kindopup menu, name:"Calculate figure using:", menu items:{"Radius of limiting circle", "Length of each segment"}, value:"Radius of limiting circle"}, ¬
{kind:text field, name:"Value for calculations:", value:"1024"}, ¬
{kind:text field, name:"X value of center coordinate:", value:"0"}, ¬
{kind:text field, name:"Y value of center coordinate:", value:"0"}, ¬
{kind:text field, name:"Degrees rotated:", value:"90"}, ¬
{kind:text field, name:"Width (±points):", value:"0"}, ¬
{kind:check box, name:"(ignore this)", value:unchecked state}} ¬
buttons {"Enter", "Quit"} default button 1
set numSides to value of item 1 of fields returned of myResult
if value of item 2 of fields returned of myResult is "Length of each segment" then
set LEN to value of item 3 of fields returned of myResult
set RAD to LEN / (sqrt ((1 - (cos of ((2 * pi) / numSides))) * 2))
--set RAD to (LEN / (sqrt (2 * (2 * (cos of ((2 * pi) / numSides))))))
else
set RAD to value of item 3 of fields returned of myResult
end if
set Xcons to value of item 4 of fields returned of myResult
set Ycons to value of item 5 of fields returned of myResult
set DEG to value of item 6 of fields returned of myResult
--set DEG to DEG + -180
set RAD to RAD - (2 * RAD)
set WID to value of item 7 of fields returned of myResult
end if
Anyway, this was only done in applescript, not xtools, so I can't give you guys a port. Just thought you might want to see some simple mac programming. See if you can follow the math... muhahahah!
(I know, I know, there are things line sin (2pi) as mutipliers with no variables, but that's just me being cautious.)
(source continued in next post)
try
set iniAsk to display better dialog ¬
"" fields ¬
{{kindopup menu, name:"Figure type:", menu items:{"Regular polygon", "Sine wave", "Cosine wave"}, value:"Regular polygon"}} ¬
buttons {"Enter", "Quit"} default button 1
set figType to value of item 1 of fields returned of iniAsk
if button returned of iniAsk is "Quit" then
quit
end if
if value of item 1 of fields returned of iniAsk is "Regular polygon" then
set myResult to display better dialog ¬
"Regular polygon:" fields ¬
{{kind:text field, name:"Number of segments:", value:""}, ¬
{kindopup menu, name:"Calculate figure using:", menu items:{"Radius of limiting circle", "Length of each segment"}, value:"Radius of limiting circle"}, ¬
{kind:text field, name:"Value for calculations:", value:"1024"}, ¬
{kind:text field, name:"X value of center coordinate:", value:"0"}, ¬
{kind:text field, name:"Y value of center coordinate:", value:"0"}, ¬
{kind:text field, name:"Degrees rotated:", value:"90"}, ¬
{kind:text field, name:"Width (±points):", value:"0"}, ¬
{kind:check box, name:"(ignore this)", value:unchecked state}} ¬
buttons {"Enter", "Quit"} default button 1
set numSides to value of item 1 of fields returned of myResult
if value of item 2 of fields returned of myResult is "Length of each segment" then
set LEN to value of item 3 of fields returned of myResult
set RAD to LEN / (sqrt ((1 - (cos of ((2 * pi) / numSides))) * 2))
--set RAD to (LEN / (sqrt (2 * (2 * (cos of ((2 * pi) / numSides))))))
else
set RAD to value of item 3 of fields returned of myResult
end if
set Xcons to value of item 4 of fields returned of myResult
set Ycons to value of item 5 of fields returned of myResult
set DEG to value of item 6 of fields returned of myResult
--set DEG to DEG + -180
set RAD to RAD - (2 * RAD)
set WID to value of item 7 of fields returned of myResult
end if