Topic: Using SIN, RAD, COS to draw angles and a circle (Read 141 times)
member is offline
Using SIN, RAD, COS to draw angles and a circle
« Thread started on: Nov 8th, 2017, 02:28am »
This example appears to be 3 times faster on BBCSDL..
It would be interesting to know how to create depth also with this method.
Uses: could be used for clock displays, gauges, and other indicators.
FNhdegdist(degrees,length)-for returning a horizontal location
FNvdegdist(degrees,length)-for returning a vertical location
Of course you would combine them into a line or many lines:
**** creates a line at 300,300 with a length of 300 pixels at a angle of 45 degrees.
and then there is:
PROC_anglelocationdist(degrees%,sx%,sy%,RETURN vs%,RETURN vy%)
sx% and sy% really just hold the length (100) --I could have made one number, but to show how it relates to horizontal and vertical lengths I did it this way.
would return a 90 degree 100 pixel lengths coordinates for h% and v%
And h% and v% would be replaced with variables you are using.
If you want you could change this procedure to:
DEF PROC_anglelocationdist(degrees%,dist%,RETURN vs%,RETURN vy%)
and then you would discard sx% and sy% and replace them with dist%
REM if you are reading this, you are seeing an experiment in progress.. unknown effects (ok its known)
REM draw a line from 300,300 to 100 points in a 45 degree angle
FOR dv%=1 TO 150 STEP 2
COLOUR 0,250-i,200-i,210-i : GCOL 0
REM horizontal degrees and length
REM vertical degrees and length
REM using this Procedure, sx%*SIN RAD gives the Horizontal distance in radians (sx%-requested distance)
REM and sy%*COS RAD(degrees%) gives the Vertical distance in radians(sy%-distance)
DEF PROC_anglelocationdist(degrees%,sx%,sy%,RETURN vs%,RETURN vy%)
vs%=sx%*SIN RAD(degrees%):vy%=sy%*COS RAD(degrees%)
REM x,y sizex, sizey
FOR d%=0 TO 360
PROC_anglelocationdist(d%,sx,sy,xs%,yc%):REM 45 degree angle at a scale of 100
REM center will be x,y
FOR x%=0 TO s
IF r% <2 THEN r%=2
IF g% <2 THEN g%=2
IF b%<2 THEN b%=2
IF r%<50 AND g%<50 AND b%<50 THEN skip%=TRUE
IF skip%=FALSE THEN
COLOUR 1,r%,g%,b%:GCOL 1
REM PROC_triangle(x,y,size)- Just a sizable triangle. you set color
REM LINE x-c%,y,x+c%,y
|« Last Edit: Nov 8th, 2017, 03:38am by michael »
I like reinventing the wheel, but for now I will work on tools for D3D