473,543 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Circle Hell

Hi all,

I am new to Tk, so please bear with me. I need someone better at math
than me to help me figure this out. I am drawing multiple arcs on the
same circle. All arcs start at 90 and have varying negative extents
(different colors, goes all the way around. Represents a microbial
genome). So now that my arcs are drawn, I would would like to draw a
line, 25 pixels long that starts on the circle at the endpoint of each
of the arcs, and looks like an extension of the radius extending above
the circle. Then I would like to print text at the end of this line. So
my question is how do I dynamically calculate the line coordinates?
Circle size is fixed, number of arcs and their extents are variable.

Code for drawing arc;
$x1,$y1 = 25
$x2,$y2 = 775
$xcenter = $x2/2 + $x1;
$ycenter = $y2/2 + $y1;

$canvas->createArc($x1, $y1,$x2,$y2,
-width=>10,
-outline=>$color s[$color],
-style=>'arc',
-start=>90,
-extent=>-$actual_angle,
-tags=>$myorfs{$ key}[1]);

What I have so far to draw lines:

$xstart = (cos($current_a rclength)*$radi us+$xcenter) /10;
$ystart = (sin($current_a rclength)*$radi us+$ycenter) /10;
$canvas->createLine($xs tart+$xcenter,
$ystart+$ycente r,
$xstart+($xstar t*0.01)+$xcente r,
$ystart+($ystar t*0.01)+$ycente r);

This draws an oval of lines, inside the orginal circle, with the line
length having sin periodicity around the circle. Can anyone improve my
math so that I can get the lines placed properly with the proper length?

Please email me directly as well as respond to the list. Thanks so much
in advance.

--Math Challenged Mark

Ma**********@ba yer.com
Jul 18 '05 #1
2 2155
On Thu, 04 Sep 2003 07:55:18 -0700, Talon <ta*****@hotmai l.com> (by way of Talon <ta*****@hotmai l.com>) wrote:
Hi all,

I am new to Tk, so please bear with me. I need someone better at math
than me to help me figure this out. I am drawing multiple arcs on the
same circle. All arcs start at 90 and have varying negative extents
(different colors, goes all the way around. Represents a microbial
genome). So now that my arcs are drawn, I would would like to draw a
line, 25 pixels long that starts on the circle at the endpoint of each
of the arcs, and looks like an extension of the radius extending above
the circle. Then I would like to print text at the end of this line. So
my question is how do I dynamically calculate the line coordinates?
Circle size is fixed, number of arcs and their extents are variable.

Code for drawing arc;
$x1,$y1 = 25
$x2,$y2 = 775
$xcenter = $x2/2 + $x1;
$ycenter = $y2/2 + $y1;

$canvas->createArc($x1, $y1,$x2,$y2,
-width=>10,
-outline=>$color s[$color],
-style=>'arc',
-start=>90,
-extent=>-$actual_angle,
-tags=>$myorfs{$ key}[1]);

What I have so far to draw lines:

$xstart = (cos($current_a rclength)*$radi us+$xcenter) /10;
$ystart = (sin($current_a rclength)*$radi us+$ycenter) /10; These look ok except dividing by 10, assuming the units for the angle are ok (degrees vs radians?)
Dividing by 10 seems weird here, so try leaving it out.
$canvas->createLine($xs tart+$xcenter,
$ystart+$ycente r, From above, xstart already has xcenter in it, so don't add it again. Same for ycenter. $xstart+($xstar t*0.01)+$xcente r,
$ystart+($ystar t*0.01)+$ycente r); If you want to draw a 25-pixel line, where is the "25"? You just need to resolve the 25
into x and y components and add them to your respective starting points, I would think.
So UIAM the above becomes (giving a name to the 25-pixel length (assuming dimensions are in pixels)

$tick_length = 25.0;

$xstart = cos($current_ar clength)*$radiu s+$xcenter;
$ystart = sin($current_ar clength)*$radiu s+$ycenter;

$canvas->createLine($xs tart,
$ystart,
$xstart+ cos($current_ar clength)*$tick_ length,
$ystart+ sin($current_ar clength)*$tick_ length);

This draws an oval of lines, inside the orginal circle, with the line
length having sin periodicity around the circle. Can anyone improve my
math so that I can get the lines placed properly with the proper length?

Please email me directly as well as respond to the list. Thanks so much
in advance.

--Math Challenged Mark

Ma**********@b ayer.com


HTH

Regards,
Bengt Richter
Jul 18 '05 #2
> $xstart = (cos($current_a rclength)*$radi us+$xcenter) /10;
$ystart = (sin($current_a rclength)*$radi us+$ycenter) /10;


I wouldn't be using lengths of arcs, if I were you. And that division
by 10 looks a bit odd, too.

Given a circle of radius r, if the arc stops at an angle theta to the
horizontal (measured anticlockwise from the east), then the point on
the circle is:
x = xcentre + r * cos(theta)
y = ycentre + r * sin(theta)

If you want to know the point at a distance 25 from the circle, simply
substitute (r + 25) in the formula above.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1768
by: Talon | last post by:
Hi all, I am new to Tk, so please bear with me. I need someone better at math than me to help me figure this out. I am drawing multiple arcs on the same circle. All arcs start at 90 and have varying negative extents (different colors, goes all the way around. Represents a microbial genome). So now that my arcs are drawn, I would would...
8
3369
by: Stub | last post by:
In statement: Circle c1=c2; Is the assignment operator= of Circle called? In statement Circle c1(c2); Is the copy constructor called?
1
7022
by: rdeaton | last post by:
I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the calculation needed, and the radius of the circle. The program should continue to ask the user for values until the user enters 'Q' as the calculation...
0
1932
by: Chua Wen Ching | last post by:
Hi.. just wonder i draw a circle in the picturebox1 1) and i want to store the circle in memory (only circle) when i store into bmp... i want to see the circle with transparent backrground...
14
3579
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell me there's a better way to do this. import numpy def circle(field=None,radius,center=(0,0),value=255,): '''Returns a list of points within...
0
3785
by: Carl Gilbert | last post by:
Hi I am trying to plot a series of shapes in a circular fashion. All shapes are evenly spaced with lines going between each shape. At present, all shapes are the same size so I can easily plot the shapes evenly around a circle. As I add more shapes, I just increase the radius of the circle. I'm calculating the radius as follows: Dim m...
9
5507
by: saraaana | last post by:
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s radius, diameter, circumference, and area. Your program must have at least the following functions: a. distance: This...
7
3221
by: heterodon7 | last post by:
hello, can anyone give me a clue or simple code on task: for example we have in 2D an equation fo circle: (x - 3)^2 + (y - 4)^2 = 25. now the program must return for example a 40 pairs of points (x,y) which belong to this cirlce. and these points must be taken evenly form the circle because i need them for planning a trajectory in CNC.
14
14491
by: DeadSilent | last post by:
I have this code and for some reason I keep getting an error where it says "exporting non-public type through public api ".. I'm not sure why this keeps happening but it does so for getCircleInfo / drawCircle. Thanks for your help. - Me. package shapemaker; import java.awt.*; import javax.swing.*;
0
7347
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7590
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7344
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5264
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3388
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1814
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
963
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.