#30818 - 07/25/12 01:33 AM
Spiral Rotation
|
Member
Registered: 12/12/01
Posts: 2893
Loc: Sydney Australia
|
Basic code for a macro. Type "GG" and paste into the Debugger to test.
;***** SPIRAL-ROTATION.GXM (BHo 7.12) /VLC; /VPT,0,@; centre of rotation /VPT,1,@; start point for rotation on x-axis rotation 0 /VRL,2,$X(1)-$X(0); base radius /VIN,10,~,/VIN,11,$I(10); number of legs per full 360 turn /VRL,3,360/$I(10); angular pitch /VRL,1,~; increase in radius for each leg /VIN,1,1; rotation counter /VIN,0,1; direction cw (-1) or ccw (1) /VIN,2,1; decreasing (-1) increasing (1) radius .LOOP; /VRL,4,$R(2)+$I(2)*$I(1)*$R(1); rotation radius from P0 /VPT,2,$X(0)+$R(4)*$COS($I(0)*$I(1)*$R(3)),$Y(0)+$R(4)*$SIN($I(0)*$I(1)*$R(3)); PO,$X(2),$Y(2); new rotated point L1,$X(1),$Y(1),$X(2),$Y(2); draw this leg /VPT,1,$X(2),$Y(2); save end point as start point for next leg .FULL360TURN; press ESC to exit /IF,$I(1)[GE]$I(10),/VIN,10,$I(10)+$I(11),/CIN,/IF,$DERR[EQ]-2,/EXIT; /VIN,1,$I(1)+1; /GTO,LOOP;
|
|
Top
|
|
|
|
#30828 - 07/26/12 06:33 AM
Re: Spiral Rotation
[Re: Bjorn Holmgren]
|
Member
Registered: 12/12/01
Posts: 2893
Loc: Sydney Australia
|
Same code with prompts. Next will include controls. (This is more fun than doing crosswords).
;***** SPIRAL-ROTATION.GXM (BHo 7.12) /MSP,++,/VLC; /PMT,1,'Pick centre of rotation :_',#,/VPT,0,@; /PMT,1,'Pick Start Point for Spiral :_',#,/VPT,1,@; /VRL,2,$X(1)-$X(0); base radius /PMT,2,'Set Number of Legs per 360 turn :_',#,/VIN,10,~,/VIN,11,$I(10); /VRL,3,360/$I(10); angular pitch /PMT,3,'Set increase in Radius per Leg - base radius(',$R(2),') :_',#,/VRL,1,~; .CONTROLS; /VIN,1,1; rotation counter /VIN,0,1; direction cw (-1) or ccw (1) /VIN,2,1; decreasing (-1) increasing (1) radius .LOOP; /VRL,4,$R(2)+$I(2)*$I(1)*$R(1); rotation radius from P0 /VPT,2,$X(0)+$R(4)*$COS($I(0)*$I(1)*$R(3)),$Y(0)+$R(4)*$SIN($I(0)*$I(1)*$R(3)); PO,$X(2),$Y(2); new rotated point L1,$X(1),$Y(1),$X(2),$Y(2); draw this leg /VPT,1,$X(2),$Y(2); save end point as start point for next leg /IF,$I(1)[LT]$I(10),/VIN,1,$I(1)+1,/GTO,LOOP; .EXITPROVISION; MD,$X(0),$Y(0),$X(1),$Y(1),PU,/IF,$VAL[LT]$ABS($R(1)),/EXIT; /PMT,1,'FULL360TURN - press ESC to exit - or any other key to continue ...',#; /VIN,10,$I(10)+$I(11),/CIN,/IF,$DERR[EQ]-2,/EXIT; /GTO,LOOP;
|
|
Top
|
|
|
|
#30830 - 07/26/12 09:33 PM
Re: Bjorn
[Re: Bjorn Holmgren]
|
Member
Registered: 08/02/07
Posts: 492
Loc: Los Angeles area
|
|
|
Top
|
|
|
|
#30831 - 07/27/12 12:25 AM
Re: Spiral Rotation
[Re: Bjorn Holmgren]
|
Member
Registered: 12/12/01
Posts: 2893
Loc: Sydney Australia
|
Controls included, no doubt some is missing. These two are drawn with rotation point and start point in the centre and width picked at the end of the y=0 radius, the number of full turns set at 5, the left one CCW and the right one CW. For macro see next post. The macro draws the spiral as a series of lines. The CVs shown are from using Pline-to-curve.gxm found in the Samples folder. Just make sure the lines are on a separated folder and that AL is OFF. Nice to make use of that old macro.
|
|
Top
|
|
|
|
#30832 - 07/27/12 12:26 AM
Re: Spiral Rotation
[Re: Bjorn Holmgren]
|
Member
Registered: 12/12/01
Posts: 2893
Loc: Sydney Australia
|
;***** SPIRAL-ROTATION.GXM (BHo 7.12) /MSP,++,/VLC; MO,OR,--; /PMT,1,'Pick centre of rotation :_',#,/VPT,0,@,/IF,$DERR[EQ]-2,/EXIT; /PMT,2,'Pick Start Point for Spiral :_',#,/VPT,1,@,/IF,$DERR[EQ]-2,/EXIT; /PMT,3,'Pick Point for Width of Spiral :_',#,/VPT,4,@,/IF,$DERR[EQ]-2,/EXIT; MD,$X(0),$Y(0),$X(1),$Y(1),PU,/VRL,2,$VAL; base radius M2,$X(0),$Y(0),$X(1),$Y(1),/VRL,0,$VAL; starting angle /PMT,3,#,/PMT,1,'Start Angle(',$R(0),') - Start Radius(',$R(2),')',#; /PMT,2,'Set Pitch - Number of Legs per 360 turn :_',#,/VIN,10,~,/IF,$DERR[EQ]-2,/EXIT; /VIN,11,$I(10),/VRL,3,360/$I(10); angular pitch /VIN,4,-1; /PMT,3,'<ENTER> to pause after each turn',#; /PMT,2,'Set Number of full 360 Turns within Overall Width :_',#,/VIN,4,~,/IF,$DERR[EQ]-2,/EXIT; .INCREMENT; MD,$X(0),$Y(0),$X(4),$Y(4),PU,/VRL,4,$VAL; half width /VRL,1,($R(4)-$R(2))/($I(10)*$ABS($I(4))); increment .CONTROLS; /VIN,0,1; direction cw (-1) or ccw (1) /VIN,2,1; decreasing (-1) increasing (1) radius .ROTANDRADIUS; /VST,8,CCW,/VST,7,Increasing; /IF,$I(0)[EQ]-1,/VST,8,CW; /IF,$I(2)[EQ]-1,/VST,7,Reducing; /PMT,3,'Enter to accept - ESC TO exit',#,/PMT,1,'Rotation ',$S(8),' - Radius Incrementation ',$S(7),#; /PMT,2,'Change_[R]otation_:_(',($I(0),') Change_[I]ncrementation_:_(',$I(2),')',#,/CIN; /IF,$STR[EQ]R,/VIN,0,$I(0)*(-1),/GTO,ROTANDRADIUS; /IF,$STR[EQ]I,/VIN,2,$I(2)*(-1),/GTO,ROTANDRADIUS; /IF,$DERR[EQ]-2,/EXIT; .COUNTER; /VIN,1,1; rotation counter .LOOP; /VRL,4,$R(2)+$I(2)*$I(1)*$R(1); rotation radius from P0 /VPT,2,$X(0)+$R(4)*$COS($R(0)+$I(0)*$I(1)*$R(3)),$Y(0)+$R(4)*$SIN($R(0)+$I(0)*$I(1)*$R(3)); ;;;PO,$X(2),$Y(2); new rotated point - take off the ;;; if you want these shown L1,$X(1),$Y(1),$X(2),$Y(2); draw this leg - block this with ;;; if you only want the points /VPT,1,$X(2),$Y(2); save end point as start point for next leg /IF,$I(1)[LT]$I(10),/VIN,1,$I(1)+1,/GTO,LOOP; .EXITPROVISION; /IF,$I(4)[EQ]1,/EXIT; MD,$X(0),$Y(0),$X(1),$Y(1),PU,/IF,$VAL[LT]$ABS($R(1)),/EXIT; /VIN,10,$I(10)+$I(11); /IF,$I(4)[GT]1,/VIN,4,$I(4)-1,/GTO,LOOP; /PMT,1,'FULL360TURN - press ESC to exit - or any other key to continue ...',#; /CIN,/IF,$DERR[EQ]-2,/EXIT; /GTO,LOOP;
Edited by Bjorn Holmgren (07/29/12 07:49 PM) Edit Reason: MO,OR,--; added at start
|
|
Top
|
|
|
|
#30835 - 07/28/12 06:32 AM
Re: Spiral Rotation
[Re: Bjorn Holmgren]
|
Member
Registered: 01/06/02
Posts: 1082
Loc: Haida Gwaii
|
Very slick Bjorn ;-) Fun stuff
|
|
Top
|
|
|
|
#30836 - 07/28/12 11:32 PM
Re: Spiral Rotation - Bjorn
[Re: Bjorn Holmgren]
|
Member
Registered: 08/02/07
Posts: 492
Loc: Los Angeles area
|
Something seems broken in that latest posted macro Bjorn. I have tried it a few times, even drawing 2 starting circles first so I could pick the different points the macro asks for in the 1st 2 prompts.
What I end up with are a series of straight lines heading into the outer limits..
Maybe I am broken..could be. How about a pictorial example for the various steps?
|
|
Top
|
|
|
|
#30838 - 07/29/12 08:20 PM
Re: Spiral Rotation - Bjorn
[Re: Bjorn Holmgren]
|
Member
Registered: 08/02/07
Posts: 492
Loc: Los Angeles area
|
Bjorn..hmm, the line MO,OR,--; is already in your macro. I will place AL,++,SY,++; just below that and see what happens. More fun than crossword puzzles  Ten minutes later +/- Bjorn... Here is what my copy of your macro, with the added lines you told me to place in it, turned out. The red circles were my guides, the white crosses my start points, the green lines the macro output Here is my copy of your macro, edited like you instructed. ;***** SPIRAL-ROTATION.GXM (BHo 7.12) /MSP,++,/VLC; MO,OR,--; AL,++,SY,++; /PMT,1,'Pick centre of rotation :_',#,/VPT,0,@,/IF,$DERR[EQ]-2,/EXIT; /PMT,2,'Pick Start Point for Spiral :_',#,/VPT,1,@,/IF,$DERR[EQ]-2,/EXIT; /PMT,3,'Pick Point for Width of Spiral :_',#,/VPT,4,@,/IF,$DERR[EQ]-2,/EXIT; MD,$X(0),$Y(0),$X(1),$Y(1),PU,/VRL,2,$VAL; base radius M2,$X(0),$Y(0),$X(1),$Y(1),/VRL,0,$VAL; starting angle /PMT,3,#,/PMT,1,'Start Angle(',$R(0),') - Start Radius(',$R(2),')',#; /PMT,2,'Set Pitch - Number of Legs per 360 turn :_',#,/VIN,10,~,/IF,$DERR[EQ]-2,/EXIT; /VIN,11,$I(10),/VRL,3,360/$I(10); angular pitch /VIN,4,-1; /PMT,3,'<ENTER> to pause after each turn',#; /PMT,2,'Set Number of full 360 Turns within Overall Width :_',#,/VIN,4,~,/IF,$DERR[EQ]-2,/EXIT; .INCREMENT; MD,$X(0),$Y(0),$X(4),$Y(4),PU,/VRL,4,$VAL; half width /VRL,1,($R(4)-$R(2))/($I(10)*$ABS($I(4))); increment .CONTROLS; /VIN,0,1; direction cw (-1) or ccw (1) /VIN,2,1; decreasing (-1) increasing (1) radius .ROTANDRADIUS; /VST,8,CCW,/VST,7,Increasing; /IF,$I(0)[EQ]-1,/VST,8,CW; /IF,$I(2)[EQ]-1,/VST,7,Reducing; /PMT,3,'Enter to accept - ESC TO exit',#,/PMT,1,'Rotation ',$S(8),' - Radius Incrementation ',$S(7),#; /PMT,2,'Change_[R]otation_:_(',($I(0),') Change_[I]ncrementation_:_(',$I(2),')',#,/CIN; /IF,$STR[EQ]R,/VIN,0,$I(0)*(-1),/GTO,ROTANDRADIUS; /IF,$STR[EQ]I,/VIN,2,$I(2)*(-1),/GTO,ROTANDRADIUS; /IF,$DERR[EQ]-2,/EXIT; .COUNTER; /VIN,1,1; rotation counter .LOOP; /VRL,4,$R(2)+$I(2)*$I(1)*$R(1); rotation radius from P0 /VPT,2,$X(0)+$R(4)*$COS($R(0)+$I(0)*$I(1)*$R(3)),$Y(0)+$R(4)*$SIN($R(0)+$I(0)*$I(1)*$R(3)); ;;;PO,$X(2),$Y(2); new rotated point - take off the ;;; if you want these shown L1,$X(1),$Y(1),$X(2),$Y(2); draw this leg - block this with ;;; if you only want the points /VPT,1,$X(2),$Y(2); save end point as start point for next leg /IF,$I(1)[LT]$I(10),/VIN,1,$I(1)+1,/GTO,LOOP; .EXITPROVISION; /IF,$I(4)[EQ]1,/EXIT; MD,$X(0),$Y(0),$X(1),$Y(1),PU,/IF,$VAL[LT]$ABS($R(1)),/EXIT; /VIN,10,$I(10)+$I(11); /IF,$I(4)[GT]1,/VIN,4,$I(4)-1,/GTO,LOOP; /PMT,1,'FULL360TURN - press ESC to exit - or any other key to continue ...',#; /CIN,/IF,$DERR[EQ]-2,/EXIT; /GTO,LOOP;
Edited by Paul Plutae (07/29/12 08:31 PM)
|
|
Top
|
|
|
|
#30839 - 07/30/12 07:11 AM
Re: Spiral Rotation - Bjorn
[Re: Paul Plutae]
|
Member
Registered: 12/12/01
Posts: 2893
Loc: Sydney Australia
|
Thanks Paul, The prompts might be unclear. To illustrate the intention, in this pic : C = Rotation Center Pick S = Start Point for Spiral W = Width of spiral measured from Start Point Looks like you used the rightmost option in this pic. The intention is for the width of the spiral to be the distance Start Point/Width Point. If S and W coincide then the width is 0 and you draw circle(s).
Edited by Bjorn Holmgren (07/30/12 07:33 AM)
|
|
Top
|
|
|
|
#30840 - 07/30/12 07:45 AM
Re: Spiral Rotation - Bjorn
[Re: Bjorn Holmgren]
|
Member
Registered: 08/02/07
Posts: 492
Loc: Los Angeles area
|
The prompts might be unclear. Not anymore Bjorn  Grasshopper thanks you!
|
|
Top
|
|
|
|
|
|
0 registered (),
3
Guests and
Spiders online. |
|
Key:
Admin,
Global Mod,
Mod
|
|
1922 Members
25 Forums
4035 Topics
27924 Posts
Max Online: 192 @ 10/26/12 11:58 AM
|
|
|
|
|
|
1
|
2
|
3
|
4
|
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
|
26
|
27
|
28
|
29
|
30
|
31
|
|
|
|