Triangles.. like the triforce maybe help me with math. Code posted

Started by LemonWizard, March 18, 2014, 01:47:34 AM

Previous topic - Next topic

LemonWizard

Does anyone have any idea how this could be done better it's as far as I got and i'm not doing well on it.
While I'm happy with the results I can't get the triangles to behave properly.
thanks in advance


PlayBASIC Code: [Select]
; PROJECT : polygon rotations test
; AUTHOR : Programming-PC
; CREATED : 3/17/2014
; ---------------------------------------------------------------------

SETFPS 60


ink rgb(200, 150, 150)

type pp
x#
y#
endtype

rotation#=0

dim p(3) as pp
p(1).x#=150
p(1).y#=150
p(2).x#=50
p(2).y#=150
p(3).x#=200
p(3).y#=200



main:

drawpoints()
angle#=rotatepoints(angle#)

//rotation=rotation+1
//if rotation>360 then rotation=1

sync
cls rgb(255, 255, 255)


goto main


function drawpoints()

x1#=p(1).x#
x2#=p(2).x#
x3#=p(3).x#
y1#=p(1).y#
y2#=p(2).y#
y3#=p(3).y#


//line p(1).x#, p(1).y#, p(2).x,# p(2).y#
//line p(2).x#, p(2).y#, p(3).x#, p(3).y#
//line p(3).x#, p(3).y#, p(1).x#, p(1).y#

//line x1#, y1#, x2#, y2#
//line x2#, y2#, x3#, y3#
//line x3#, y3#, x1#, y1#


tri x1#, y1#, x2#,y2#, x3#, y3#

tri x1#+150, y1#+100, x2#+150, y2#+100, x3#+150, y3#+100

tri x1#+50, y1#+100, x2#+50, y2#+100, x3#+50, y3#+100


endfunction

function rotatepoints(angle#)

For lp=1 to 3
angle#=wrapangle(angle#,lp*(360.0/3))
x#=p(lp).x+cosradius(angle#,2)//+mousex()
y#=p(lp).y+sinradius(angle#,2)//+mousey()
angle#=wrapangle(angle#,360)
//DrawRotatedImage Image_Ball,x#,y#,angle#,1,1,BallWidth/-2,BallHeight/-2,true+8
p(lp).x#=x#
p(lp).y#=y#
next lp


angle#=angle#+2
ink rgb(angle#*2, angle#, angle#/2)

//if angle#>360 then angle#=0






endfunction angle#



monkeybot

what are you actually trying to do?


shapes are handy for vector stuff

kevin