![]() |
Forum Index : Microcontroller and PC projects : Maximite polygon patterns
Page 1 of 3 ![]() ![]() |
|||||
Author | Message | ||||
maxidavid Newbie ![]() Joined: 07/03/2019 Location: AustraliaPosts: 23 |
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: AustraliaPosts: 1097 |
Hi Maxidavid You may find some programs amongst these listings here Brian Oh, & welcome to the Forum ChopperP |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
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: AustraliaPosts: 23 |
Hi, Can you give an example for MMBasic ? Thanks |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
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: AustraliaPosts: 1114 |
@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: AustraliaPosts: 655 |
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: AustraliaPosts: 23 |
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: AustraliaPosts: 655 |
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: AustraliaPosts: 1114 |
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: AustraliaPosts: 23 |
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 |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
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: AustraliaPosts: 23 |
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 |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
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: AustraliaPosts: 6283 |
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. Jim VK7JH MMedit |
||||
maxidavid Newbie ![]() Joined: 07/03/2019 Location: AustraliaPosts: 23 |
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 |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
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 |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
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: AustraliaPosts: 23 |
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 KingdomPosts: 2170 |
"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 |
||||
Page 1 of 3 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |