Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:51 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 2 of 3    
Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:01pm 12 Mar 2019
Copy link to clipboard 
Print this post

  maxidavid said  ... I tried the code and it didn't work and I haven't found the problem.


What kind of "didn't work"? Didn't draw what you expected, or what? Do you have a photo of what it did draw? And perhaps a sketch or explanation of what you were hoping for?

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
TassyJim

Guru

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

  maxidavid said   Hi,

Thanks for the translation.
I tried the code and it didn't work and I haven't found the problem.


The code runs on my colour maximite.
Do you have a colour or mono maximite?
What version of MMBasic?

What was the error (including the line number)?

If we can get my code example working for you, I will draw a polygon for you.
But I need to know why my code didn't work first.

Jim
VK7JH
MMedit
 
TassyJim

Guru

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

Try this one
  Quote   CLS
MODE 3
cX =
MM.HRES/2 ' define centre of circle as centre of screen
cY = MM.VRES/2
r =
MM.VRES/3 ' radius of circle
sX = 0.7 ' change shape of circle to suit different displays
s = 15 ' number of sides on the polygon
st = 4 ' number of points to step through
z = 0 ' zero or starting point in degrees

DIM allPoints(s,2) ' size an array to hold all x,y points

FOR n = 0 TO s-1 ' fill the array with the nodes of the polygon
a = 2*PI/s * n 'angle to rotate per side in radians
allPoints(n,1) = cX + r*COS(a + RAD(z))* sX
allPoints(n,
2) = cY + r*SIN(a + RAD(z))
'print allPoints(n,1), allPoints(n,2)
NEXT n

FOR n = 0 TO s-1 ' plot the nodes
PIXEL(allPoints(n,1),allPoints(n,2)) = WHITE
NEXT n
PAUSE 5000
n =
0
DO ' plot lines between nodes
x1 = allPoints(n,1)
y1 = allPoints(n,
2)
n = (n + st)
MOD s
x2 = allPoints(n,
1)
y2 = allPoints(n,
2)
LINE (x1,y1) - (x2,y2), RED
PAUSE 500
LOOP


and if it has an error, please tell me the error so I can work out what the probelm is.

Play with s, st and z to see the different results.
sX will give you ellipses.

Jim
VK7JH
MMedit
 
PeterB
Guru

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

G'Day Jim

Thanks for that, you have verified my theory.
The big difference is, you plot the points and then join them. I just wanted to draw the line after converting from polar to cart.
But I am pleased and one day when I have time I will try writing the code.

Peter
 
maxidavid
Newbie

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

Hi,

I have 4.5C MMBasic.
I will type it in again to see if it works.

I typed EDIT and then the code then F1 to save.

Then RUN

I only got a straight diagonal line.

Thanks again.
Edited by maxidavid 2019-03-14
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 06:20am 13 Mar 2019
Copy link to clipboard 
Print this post

I'm not really sure what the first program is supposed to show but they both work for me. I'm using Jim's MMEdit and just a copy and paste to put them into MMEdit. I suggest that you have a typo in your entry.

Bill
Keep safe. Live long and prosper.
 
TassyJim

Guru

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

  maxidavid said  
I only got a straight diagonal line.


It looks like you are not getting the reversal of X working
IF X > MM.HRES-SPEED OR X < SPEED THEN XADD=-XADD

This should send the line back again.
Similar for the Y line.
You could put a PRINT statement in to see what is happening to X

Jim
VK7JH
MMedit
 
PeterB
Guru

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

This is my 2 bobs worth.

CLS
CPU 100

X0 = 200'x start
Y0 = 200'Y start
N = 7'number of sides
L = 50'length of side

For I = 0 to (N-1)
XN = X0 + L * Cos(I * 6.28/N)
YN - Y0 + L * Sin(I * 6.28/N)

Line X0,Y0,XN,YN

X0 = XN
Y0 = YN

NEXT I

It runs on an E100 with a 7in touch screen

In the getting to work I used degrees instead of radians i.e. 360 instread of 6.28.
The results were quite interesting.

Peter
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 03:09pm 14 Mar 2019
Copy link to clipboard 
Print this post

On an Armmite H7 with 4.3" SSD1963, this
[code]
> list
Option default float
CLS
CPU 100

X0 = 100 'x start
Y0 = 100 'Y start
N = 7'number of sides
L = 50'length of side

For I = 0 To (N-1)
XN = X0 + L * Cos(I * 6.28/N)
YN = Y0 + L * Sin(I * 6.28/N)

Line X0,Y0,XN,YN

X0 = XN
Y0 = YN

Next I
[/code]
produces this:


The camera (out of focus, sorry) picks up the lines as much fatter than they show on the screen.
Edited by lizby 2019-03-16
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 03:25pm 14 Mar 2019
Copy link to clipboard 
Print this post

G'Day lizby

Good on yer mate!
I started thinking this would be very very difficult and it turned out to be very very easy.
If you change both 6.28s to 360 and N to 40, you will get the sort of nail and string thing that max was talking about.
It's 2:00 am. My phone woke me up. Why do we do these things.

Peter
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 06:34pm 14 Mar 2019
Copy link to clipboard 
Print this post

Ok. Like this:



[code]
> list
Option default float
CLS
CPU 100

X0 = 100 'x start
Y0 = 100 'Y start
N = 40 'number of sides
L = 200 'length of side

For I = 0 To (N-1)
XN = X0 + L * Cos(I * 360/N)
YN = Y0 + L * Sin(I * 360/N)

Line X0,Y0,XN,YN

X0 = XN
Y0 = YN

Next I
>
[/code]

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
PeterB
Guru

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

I hope that is what max wanted.
It could be tidied up by making both 6.28s, Q x 6.28 where Q is the number of laps.
Changing L, N, Q would give a big range of shapes.

It is now 8:30 am. I went back to bed

Peter
 
maxidavid
Newbie

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

Hi,

Thank you so much for the listings.
I have been very busy and haven't had a chance to type them in.
I look forward to trying them out.
Now I have some interesting stuff to work with.
I will use all the code you guys have shared to make some interesting listings.

Thanks

 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:51pm 15 Mar 2019
Copy link to clipboard 
Print this post

  maxidavid said  Thank you so much for the listings.


Glad you brought up this topic--it looks fertile.

  maxidavid said  ... haven't had a chance to type them in.


I hope you mean cut and paste--so much less chance of frustration.

Note this is Micromite code--don't know how it compares to the older Maximite syntax.

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
maxidavid
Newbie

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

Hi,

I had to change a couple of lines to get them working.

For example:

Line X0,Y0,XN,YN

to

Line (X0,Y0)-(XN,YN)

Thanks
Edited by maxidavid 2019-03-17
 
PeterB
Guru

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

lizby, max et al

Have we a new convert?
max, have you been looking at what matherp has been doing ?

Peter
 
maxidavid
Newbie

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

Hi,

Who is matherp Peter ?

BTW I've been having fun with the polygons :), thanks Guys.

Also how can I draw an ellipse ?
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 05:39am 20 Mar 2019
Copy link to clipboard 
Print this post

Check out the circle command in the manual.

Bill
Keep safe. Live long and prosper.
 
PeterB
Guru

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

G'Day David

matherp is Peter Mather a very clever bloke who contributes a lot to this forum.
Your post got him started and now he has started a new thread "Micromite Spirograph".
The most recent entry was 17 March by me. They have generated some impressive patterns.

To generate an ellipse you can increase the number of sides to get a circle then play with adjusting the value of L in X or Y not both.

It sound like you are on the way

Peter
 
maxidavid
Newbie

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

Hi,


I meant to ask, how do I change the angle of the ellipse ?
I could not find that option in the circle command.

Is there a way ?

Thanks
 
     Page 2 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025