Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:49 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Maximite polygon patterns

     Page 1 of 3    
Author Message
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 02:17pm 08 Mar 2019
Copy link to clipboard 
Print this post

Hi,

Does anyone know a good source of polygon patterns for the Maximite ?
Im looking for short programs in MMBasic that draw polygons.

Thanks
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1097
Posted: 10:02am 09 Mar 2019
Copy link to clipboard 
Print this post

Hi Maxidavid

You may find some programs amongst these listings here

Brian

Oh, & welcome to the ForumEdited by Chopperp 2019-03-10
ChopperP
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 10:21pm 09 Mar 2019
Copy link to clipboard 
Print this post

G'Day Maxidavid

If you can't find a program it should be possible to do it using the trig function.
x = L cosA, y = L sinA

where L is the length of a side and A is the outside angle

It has been a long time since I was involved with triggerwhatsit so I hope yours is in good shape.

Good luck

Peter
 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 06:52am 10 Mar 2019
Copy link to clipboard 
Print this post

Hi,

Can you give an example for MMBasic ?

Thanks
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 06:58am 10 Mar 2019
Copy link to clipboard 
Print this post

G'Day

I can't give you the code because I haven't written it but I think it will be quite simple once you understand hoe it works.
Have you an understanding of trigonometry?

Peter
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 05:10am 11 Mar 2019
Copy link to clipboard 
Print this post

@maxidavid,

Once you get past triangles and rectangles, multi facit polygons start to get complex, particularly if you have interior angles greater than 180 degrees (eg, a St George cross) and also if you want to fill them rather than outline them.

Can you give us a bit more detail of your needs?

Another way if you only need some specific shapes would be to create them externally (paint, Draw etc.) then load as bitmaps. Alternatively, create a special bitmap font that has the shape you need and scale with the font command when you invoke the font.

panky.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 05:47am 11 Mar 2019
Copy link to clipboard 
Print this post

G'Day panky (and maxidavid)

I'm a bit worried that the threat of trigerwhatsit may have scared maxidavid off.
My theory is that for a polygon of N sides of length L:

The outside angle is 360/N
So starting at x0,y0
the first line will run to X = Lcos(360/N) and Y = Lsin(360/N)
the second line will run from that point to
X = Lcos(2x360/N) and Y = Lsin(2x360/N)
These coordinates must be added to the earlier points. i.e. they are relative not absolute. And the second line can then be drawn.
And so on.
I think the code would be for I = 1 to N etc
Since you are good enough to get involved can you check my logic please
It would be a shame if maxidavid gave up too early.

Thanks

Peter


 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 05:58am 11 Mar 2019
Copy link to clipboard 
Print this post

Hi,

Im really interested in seeing and experimenting with the line command to make interesting patterns like the nail and string type.
I believe these are called polygons for example a octagon with a line going from each corner to the opposite corner.
I used to type in short programs for the BBC Micro that showed these patterens.
I need to understand algorithms and trigonometry, very hard, so just would like some simple basic code to experiment with.
I want to produce something like LOGO or turtle graphics would produce.
I also had the Super Expander for the C64 that drew these polygons.
The Maximite has the line and circle commands I want to use.
I noticed producing ovals and putting them on an angle is really hard with MMBasic.
I just want to draw nice patterns, Thanks all :))

Thanks

 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 06:38am 11 Mar 2019
Copy link to clipboard 
Print this post

MMBASIC also has the trig function, sin, cos, tan and the inverse of these.

Let us try to explain how it works.

If we start with a clean sheet of paper and draw a nice straight horizontal line about this long. Sorry but the length doesn't matter so long as it's reasonable.
At the left hand end draw a vertical line about half as long as the first one.
Now we create a right angled triangle by joining the two ends with another nice straight line.
Then down the right hand end we call the angle B and the top angle is A (we know the other angle is 90 degrees because that's what we made it).
The long sloping line is called the hypotenuse (I hope the spelling is correct)
Now we get to the interesting bit

sinA = opposite / hypotenuse
opposite means the line opposite the angle, the horizontal line in this case.
cosA = adjacent / hypotenuse, the vertical line in this case.
sineB = opposite / hypotenuse but now the opposite is the vertical line.
cosB = adjacent / hippopotamus

tan A is opposite / adjacent

So, if you know the required angle and the length of the line and we do then,

rearrange the equations and we get X = length x cos(angle)
and Y = length x sin(angle)

To draw a line 100 units long at 60 degrees to the horizontal starting at X = 0, Y = 0 we get
X = 100 x cos60. cos 60 = 0.5 which means we need x = 50
Y = 100 x sin60. sin60 = 0.866 which means we need Y = 86.6

I hope all this helps and doesn't confuse you.

It's all good fun

Peter


 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1114
Posted: 07:19am 11 Mar 2019
Copy link to clipboard 
Print this post

Peter,

I'll have a play tomorrow - I have a Maximite here to test with.

panky

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 07:19am 11 Mar 2019
Copy link to clipboard 
Print this post

Thanks.

I never had this trouble with turtle graphice, LOGO, super expander or BBC.
There were pre-made code ready to type in and learn from.
This way you didnt need a degree in trigonometry and algorithms.
I just thought someone out there has some programs to type in and change values for different results.
I enjoyed working with the fractal code making dozens of different patterns and using SAVEBMP after it has rendered.
I would not have a clue how to make fractals, vectors or polygons using BASIC.
If its this hard, you would think after making some code it would be shared on the net for people to use.
Why has MMBasic left out the oval command ?, for example oval 35,60,A where a is the angle.
I think it was something like that for an ELIPSE.
OR. CIRCLE X,Y,A, a being the angle.

I will just try line point to point to start with and work from there but I really don't have a good understanding of the maths.

Thanks again
Edited by maxidavid 2019-03-12
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 11:13am 11 Mar 2019
Copy link to clipboard 
Print this post

This is interesting as I have an 8-year old grandson who is getting interested in programming and I'm trying to find a simple way in. I've found a simple implementation of turtle graphics that could be implemented on a Micromite.

See here for the commands that would be supported. Is this something of general interest?
 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 11:59am 11 Mar 2019
Copy link to clipboard 
Print this post

Can this BBC Micro code be converted to Maximite MMBasic ?

Without the sound part.

10 MODE 2 : VDU 19,0,6,0,0,0
20 GCOL 3,1
30 SPEED=8 : X=0 : Y=0
40 XADD=SPEED : YADD=SPEED
50 PLOT69,X,Y
60 REPEAT : OLDX=X : OLDY=Y
70 X=X+XADD : IF X > 1279-SPEED OR X < SPEED THEN XADD=-XADD :
SOUND 1,-15,200,1
80 Y=Y+YADD : IF Y > 1023-SPEED OR Y < SPEED THEN YADD=-YADD :
SOUND 2,-15,100,1
90 PLOT 69,X,Y
100 PLOT 69,OLDX,OLDY
110 UNTIL FALSE


It draws a very interesting pattern.


Thanks
Edited by maxidavid 2019-03-12
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 02:32am 12 Mar 2019
Copy link to clipboard 
Print this post

matherp:

If you think for one minute that I am going to get into a competition with the likes of you, panky, rob, et al, you are bonkers
However, being able to convert from polar to cartesian is a good thing and not difficult. I would have thought that polar coords would be used in meters and games but have not looked into that area.
Perhaps maxidavid will get more confident with experience. I hope so.

Incidentally, corrupting a minor is an offense in this country.

Peter
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:07am 12 Mar 2019
Copy link to clipboard 
Print this post

Be careful to remind us that you are using a Maximite, nor a micromite.
There are differences, especially around graphics.

This is a quick translation of your code with the warning that I don't know the syntax used in your BBC Micro example.

  Quote   CLS
MODE 3 ': VDU 19,0,6,0,0,0
'GCOL 3,1
SPEED=8 : X=0 : Y=0
XADD=SPEED : YADD=SPEED
PIXEL(X,Y) = RED 'PLOT 69,X,Y
DO
OLDX=X : OLDY=Y
X=X+XADD :
IF X > MM.HRES-SPEED OR X < SPEED THEN XADD=-XADD :
'SOUND 1,-15,200,1
Y=Y+YADD : IF Y > MM.VRES-SPEED OR Y < SPEED THEN YADD=-YADD :
'SOUND 2,-15,100,1
PIXEL(X,Y) = RED 'PLOT 69,X,Y
PIXEL(oldX,oldY) = RED 'PLOT 69,OLDX,OLDY
LINE (oldX,oldY)- (X,Y), -1
LOOP



Jim
VK7JH
MMedit
 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 08:25am 12 Mar 2019
Copy link to clipboard 
Print this post

Hi,

Thanks for the translation.
I tried the code and it didn't work and I haven't found the problem.
The way I learn is to look at a program, make changes and tinker with it.
I have been looking for pre-made code for the graphics on the Maximite.
I have had fun changing the values in the fractal sample but didn't really understand the code.

Also.

How do I draw a Elipse (ovel) on the maximite ?
It only accepts circles.

I want to draw an elipse and change the angle it is drawn like on the Micromite.

Thanks

Edited by maxidavid 2019-03-13
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 09:28am 12 Mar 2019
Copy link to clipboard 
Print this post

  PeterB said  
being able to convert from polar to cartesian <snip>


here's one I prepared earlier.


'To convert from polar to rectangular:
'x=r*(cosθ)
'y=r*(sinθ)

'To convert from rectangular to polar:
'r2=x2+y2
'tanθ=x/y <-- watch out for divide by zero error

'Preamble

CONST Deg2Rad=360/(2*Pi)
Dim Float Th,R,X,Y

'convert rectangular to polar. Give the angle and distance from 0,0 to x,y. 0 is North
Sub Polar(x As Float,y As Float,opt As Integer) ' opt 0 = radians, Not 0=degrees
If y=0 Then y=1e-6 'eliminates div zero errors

R=SQR(X*X+Y*Y)

Th=Atn(X/Y)
If Y<0 Then
Th=Th+Pi
ElseIf X<0 Then
Th=Th+2*Pi
EndIf

If opt then
Th=Th*Deg2Rad
EndIf
End Sub

Sub Rect(Th As Float,R As Float,opt As Integer) ' opt 0 = radians, Non 0=degrees
If opt then
Th=Th/Deg2Rad
EndIf

Y=R*(cos(Th))
X=R*(sin(Th))
End Sub



Edited by CaptainBoing 2019-03-13
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 09:53am 12 Mar 2019
Copy link to clipboard 
Print this post

G'Day Capt.

All I really wanted was panky or someone to check my theory about generating a polygon and now you drag in radians ans Lord knows what all. You young blokes just like making things difficult for we oldies.
Anyway, I thought Th+2*Pi was roughly equal to Th or are they different in your hemisphere

Peter
 
maxidavid
Newbie

Joined: 07/03/2019
Location: Australia
Posts: 23
Posted: 10:28am 12 Mar 2019
Copy link to clipboard 
Print this post

Hi,

All sounds very clever but all I wanted is a small Program for Maximite to produce a polygon pattern.

Is it a secret or something, I have never had this problem.
Im not a mathematician and I dont understand trigonometry, cos, sin, oldX, oldY and so on.
I just want to see the thing do something interesting.
The Maximite library was hopeless and uninteresting and thats all there is it seams.
I thought the Maximite was released 2013 and so there should be heaps of homebrew and interesting stuff to type in.

The maximite has a pixel, line and circle command, good tools.

I had a lot of fun with SUPER EXPANDER, LOGO, TURTLE GRAPHICS AND BBC ARORN.

Im just disappointed with the availability of good code listings.

It cant even produce a ELIPSE, I know work is being done on MMBasic for the Maximite but feel I'm going to battle to find code listings.

Thanks for all your help guys and have a good one.

 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2170
Posted: 10:35am 12 Mar 2019
Copy link to clipboard 
Print this post

  PeterB said   G'Day Capt.

All I really wanted was panky or someone to check my theory about generating a polygon and now you drag in radians ans Lord knows what all. You young blokes just like making things difficult for we oldies.
Anyway, I thought Th+2*Pi was roughly equal to Th or are they different in your hemisphere

Peter


"young blokes" - God bless you... that code is lifted from work I did on WindProc and MeteoProc enhancements for the Plessey WF33 (a refurb of WF3) radars for the met office in 1984... I have trouble remembering where I put my glasses now-a-days

the Th+2*Pi thing eliminates any negatives but still keeps you talking circles, effectively converting an angle into a traditional bearing - e.g if you calculate -90, (one quarter turn left) by adding 360 (2*Pi radians) to it you get 270 - which is the traditional notation for -90

Edited by CaptainBoing 2019-03-13
 
     Page 1 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025