CASLSoft.com

Welcome to the CASL Support board

[ Home ] [ News ] [ Community ] [ Products ] [ Download ] [ Support ] [ Sales ] [ About CASL ]

It is currently Thu Sep 09, 2010 7:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Trigonometry circles and angles
PostPosted: Wed Jun 16, 2010 9:04 pm 
Offline

Joined: Sat Apr 17, 2010 9:14 am
Posts: 11
What is the formula for figuring out the / an angle; knowing which way a line is pointing - where it is pointing?

I have a dial that I can move [pen_move], I would like to know [pen_up] mathematically where it is pointing and I would I to be able to reproduce that angle on a smaller dial, using the angle info from the larger dial.

The center of the dials of course will not be in the same (casl) location.
The big (input) dial is in frame by itself. The smaller dial_s_[buttons] are in another frame, their center (casl screen) locations will be different than the input dial.

The OClock sample has some info but "... and assumes some knowledge of trig.."


Top
 Profile  
 
 Post subject: Re: Trigonometry circles and angles
PostPosted: Thu Jun 17, 2010 5:19 pm 
Offline
CASL Jedi

Joined: Sat Nov 12, 2005 5:35 pm
Posts: 673
Location: Kingsport, TN
Here's the trig -

angle = arctan(delta y/ delta x)

delta y is the change in the y value from origin to the point in question, delta x is the change in x value from origin to the point in question. For example, if the center point is at 100,100 and the outer point is at 220,150 then it would be arctan((220-100)/(150-100)), which equals arctan(120/50) = 67.38 degrees.

To redraw at the same angle at another location, reverse the process. To make it smaller, make the change in x 30, for example. The math is then tan(67.38) = dy/30, or dy = 30tan(67.38) = 72. If the new line is to start at, say, 200,200 then draw a line from 200,200 to 230, 272.

The tan and arctan functions are in mathlib and also the PD math library I released for Casl.

Jeff

_________________
C Cells: C Shells by C. Schorr


Top
 Profile  
 
 Post subject: Re: Trigonometry circles and angles
PostPosted: Sat Jun 19, 2010 12:34 pm 
Offline

Joined: Sat Apr 17, 2010 9:14 am
Posts: 11
Thank you for the reply. Use of the mathlib results in a Fatal Exception Error, I will be using your library.

I will have to rereading your last reply, because I am getting what I expected.

code:
*********************
function PenUp;
variables;
numeric hold0x;
numeric hold0y;

end;
hold0x = 80;# these are the center point of the gear
hold0y = 70;# in frame 20
if Frame20.hidden = false;
#this draw is used to draw the line over the last call to
#to show the gear BMP file
draw Frame20, line, lastx - homex, lasty - homey;
clear Frame20, rectangle, 0, 0; #to clear up redraw list
# call location(homex,homey,lastx,lasty);
# FATAL EXCEPTION ang = atan2((lastx - homex) , (lasty - homey));
ang = cslASIN(lastx - homex /cslSQRT(lasty - homey * lasty - homey +1));
transx = lastx;
transy = lasty;

end_if;


end;


function getpi;
variables;
numeric hpt = 25;

numeric hold1x;
numeric hold1y;
numeric hold5x;
numeric hold5y;
end;
hide frbegin;
clear Frbegin, rectangle, 0, 0; #to clear up redraw list
show frbegin;

set Frbegin, pen, 117, 72;# center of gear
draw frbegin, line, (ang/30) - 117 , (ang/30) - 72;
# draw Frbegin, line, ((homex / 24) * pi) - hpt, ((homey / 24) * pi) - hpt;

text03.display = string(ang,"#.######");
text04.display = string(transx,"#") + ".." + string(homex,"#");
text05.display = string(transy,"#") + ".." + string(homey,"#");

end;

complete project(not the real project - it's done, would just like to add this feature) is here for june 2010 only:
http://www.mediafire.com/?nxz5ncmmoii


Thanks again, for the help I will reread and try changing for formula around, or items in formula around, no need to reply.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group