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.

Newcomers DBPro Corner / Clock hand

Author
Message
mightymax
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 5th Mar 2003 13:30
Ok, I want to make a function which alows me to enter an x coordinate, a y coordinate, a "length" value and and "angle" value. I want it to draw a line from the point in space at pointing in such a direction with a length of such or such (hope that makes sense).

I hate it when I can't figure out these simple puzzles! I can generally get the complicated ones, but the simple ones bog me down! I have several ideas, I know I can get all angles up to 90deg using SIN COS TAN etc, and then flip that to get the rest of the "circle", but does anyone know a formula for doing this type of thing which I perhaps don't know? Just that the above approach appears to be slighly messy.

I might post the code I've made once it is finished but I would like some suggestions for a better approach...

Thanks,
MAX
REM get a signature off the user
INPUT "Type your sig here",sig$
PRINT sig$
mightymax
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 5th Mar 2003 14:35
ok, here is what I have, however, it doesn't appear to work. The code is incredibly untidy, sorry. This was meant to be quick and easy!



Also, if you have suggestions, please don't just post code, I would prefer a helpful hint to point me in the right direction. Cheers.

REM get a signature off the user
INPUT "Type your sig here",sig$
PRINT sig$
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 5th Mar 2003 15:16
if i understand you wanna simulate a clock-hand?
like this:


just remember x=cos(angle)*length, y=sin(angle)*length
mightymax
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 5th Mar 2003 17:04
Do you mind explaining that to me? I can see it working but I only have a limited understanding of trig (I'm 14 so I haven't done it at school yet) I can work out angles and legths in triangles, but little else. I would like it if someone explained why the above method works. Thanks for the code though, it is just what I needed.

REM get a signature off the user
INPUT "Type your sig here",sig$
PRINT sig$
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 5th Mar 2003 17:51
Okay very basic trig:
Get a piece of paper and a pen
Draw a circle
Draw a horizontal line through centre of circle (x axis)
draw a verticle line through centre of circle (y axis)
Now get a different coloured pen.

Now from center of circle draw a straight line to circumference at an angle of about 45o (you should have a clock hand pointing to about 7.5minutes)
This line is the hypotenuse.

Now draw a line from where the hypotenuse touches the circumference straight down to the x-axis.
This line is the hieght.

Now draw a line from where the height line touches the x-axis back to the centre of the circle.
This line is the base.

Okay now if you do it all again but use a different angle for the clock hand you should see that the length of the hypotenuse stays the same but the length of the height and the base change.

The relationship between hypotenuse and height and base is:
cos(angle#)*hypotenuse=length of base
sin(angle#)*hypotenuse=length of height

origin+length of height = Y
origin+length of base = X

Anyway do the circle and triangle things I said - its much easier to understand a problem if you can visulise it.
mightymax
21
Years of Service
User Offline
Joined: 31st Jan 2003
Location:
Posted: 5th Mar 2003 18:25
Hmmm... that is almost what I was trying to do, only I had the sine & cosine reversed (which still works) and I didn't realize that tose formulas worked around 360 degrees (I guess I'm stuck to thinking in right-angled triangles) so I was trying to split the circle unneccersaily. Thanks for pointing that out.

MAX

REM get a signature off the user
INPUT "Type your sig here",sig$
PRINT sig$
KamaKase
22
Years of Service
User Offline
Joined: 29th Oct 2002
Location:
Posted: 5th Mar 2003 22:01
Hmmm, I'm fourteen and we did trig last year. hmmm...
If you're really that lazy. You could just make a sprite of a line, offset it. and then rotate it.

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 6th Mar 2003 01:22
In Reg DB you cant rotate sprites.

RPGamer

Current - RPG: Eternal Destiny
http://www.halbrosproductions.netfirms.com
Dont ask those questions! Read the help files lazy! Oh ya, and Tat has a plugin for that!

Login to post a reply

Server time is: 2024-11-24 04:08:43
Your offset time is: 2024-11-24 04:08:43