News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Shapes Rotating

Started by Big C., March 24, 2006, 09:14:22 AM

Previous topic - Next topic

Big C.

Hi,

how can I rotate a shape in the middle or whatever Point of the shape?

Or how can I get the handle of a shape from the upper-left-corner to the center or any point of the shape?

Has someone an idee?

thx Big C.

kevin

#1
The vertex in the shape rotate around zero (the shapes axis).  You can change the vertex positions by using the ShiftShape command.  



PlayBASIC Code: [Select]
   CReateShape 1,4,4

; Create 4 verts to form a box
SetShapeVertex 1,0,0,0 ; Top left coord
SetShapeVertex 1,1,100,0 ; Top Right coord
SetShapeVertex 1,2,100,100 ; Bot Right coord
SetShapeVertex 1,3,0,100 ; Bot left coord

SetShapeEdge 1,0,0,1 ; connect vertex 0 to vertex 1
SetShapeEdge 1,1,1,2 ; connect vertex 1 to vertex 2
SetShapeEdge 1,2,2,3 ; connect vertex 2 to vertex 3
SetShapeEdge 1,3,3,0 ; connect vertex 3 to vertex 0


; Copy this shape
CopyShape 1,2

; Add -50x and -50 Y to the shapes vertex. To center it
ShiftShape 2,-50,-50


Do
Cls 0

; ROtate both shapes
RotateShape 1,angle#,1.0
RotateShape 2,angle#,1.0

; draw them
ink rgb(255,255,255)
drawshape 1,200,100,2
Circlec 200,100,5,0,rndrgb() ; draw axis


drawshape 2,500,100,2
Circlec 500,100,5,0,rndrgb() ; draw axis


Angle#=wrapangle(angle#,1)

Sync
loop





Big C.

boarr Kevin,

great... thats it i have looking for (i hope i don't find this example in the Play Basic Reference, because i have searching it before but nothing find to use)

many thx for your fast help...

Big C.