Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / How can I draw a pentacle in dark basic?

Author
Message
robmaggs
19
Years of Service
User Offline
Joined: 17th Apr 2006
Location: Anglesey UK
Posted: 17th Apr 2006 16:23
Hi, I want to draw a pentacle line by line and then just get the drawing to loop. Anyone out there able to help me?

Many thanks Rob

www.moonfish-design.co.uk
General Sephiro
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location:
Posted: 17th Apr 2006 17:16
VERY EASY

Getting the co-ordinates

Firstly start off getting the points. You can create a small bit of code to do this for you. For example when you click it starts the line where you started the click, and then ends the line where you release the mouse button.

Have the starting position and ending position displayed - write them down and wolla. Do this for all the lines.



Getting it to draw it line by line
Simply entering in the data you gained from the previous exercise. Simply do it in steps. Creating the line at a certain co-ordinate, increase the lines length until it gets to the next point. Do the same for the next lines until your 'pentacle' is complete.

I would do the code for you, but where would be the learning in that?

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Apr 2006 06:02
A little bit more info to work on...

The five points of a pentangle (I'm assuming you mean a pentangle rather than a pentagon which is a completely different shape), are all lying on a circle.

As a circle is 360 degrees, you trace out a circle of the required radius, recording the X,Y starting point and the four X,Y points every 72 degrees (360 div 5), giving you 5 X,Y pairs in all.

If you store them in an array, you can use them in your line drawing routine. Eg:

Dim Pentangle(5,1)

This allow you to store 5 X,Y screen locations - the X position in Pentangle(5,0) and the Y position in Pentangle(5,1).

Assuming that the very first X,Y pair is at 0 degrees (12 o'clock), the point pairs clockwise will be array indexes 2, 3, 4 and 5.

Your line drawing routine would then draw 5 lines linking the X,Y points stored in the array, using the following array indexes:

5 >> 2
2 >> 4
4 >> 1
1 >> 3
3 >> 5

So, The first line above would draw a line from X,Y pair 5 to X,Y pair 2 with:

Line Pentangle(5,0),Pentangle(5,1),Pentangle(2,0),Pentangle(2,1)

The second line would be drawn with array indexes 2 and 4... and so on.

TDK_Man

robmaggs
19
Years of Service
User Offline
Joined: 17th Apr 2006
Location: Anglesey UK
Posted: 18th Apr 2006 12:45
Many thanks for your help, it's not that I'm "blonde"...I'm more right brain than left and logic (unless it's fuzzy or prolog based) leaves me feeling a bit

To get the co-ordinates would I use a graphics editor and get the pixel positions that way? Or are there any tools where I can map the points of a pentacle with my mouse. I'm working through both suggestions I've been sent and I really appreciate your input

Many thanks Rob

http://www.moonfish-design.co.uk

www.moonfish-design.co.uk
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 19th Apr 2006 05:33
A perfect pentangle subdivides a circle into five equal parts from each point (convex points, that is). So, 360/5 will give you the angle seperating any two consecutive points. Just use simple trig functions to find the x,y position of the points.

Another, perhaps more difficult method which would work if you had the vertices of a perfect pentagon to work off of would be to find the equations of the lines making up the sides of the pentagon, then find where the lines intersect.
Duke Blue Devils
19
Years of Service
User Offline
Joined: 11th Mar 2006
Location:
Posted: 19th Apr 2006 05:51
You could use DeMoivre's Theorem by simply specifying an angle (@) and a modulus (r). That would give you the complex number in trigonometric form: z=r(cos@+i sin@)
Then use that to form any polygon you want by raising it to a power equal to the number of sides in the polygon.
Use this formula:
z^n=r^n(cos n@+i sin n@)
This will give you the verticies of the polygon. Then just connect the dots with a little for loop and y=mx+b.

Visit the official Chicago Rush website
http://chicagorush.servegame.com/index.php
Virtual X
19
Years of Service
User Offline
Joined: 27th Feb 2006
Location:
Posted: 22nd Apr 2006 00:52
y=mx+c for ppl in the UK
robmaggs
19
Years of Service
User Offline
Joined: 17th Apr 2006
Location: Anglesey UK
Posted: 23rd Apr 2006 13:39
Thankyou for your help guys, I really appreciate it.

All the best Rob

http://www.moonfish-design.co.uk

www.moonfish-design.co.uk

Login to post a reply

Server time is: 2025-05-23 21:46:41
Your offset time is: 2025-05-23 21:46:41