473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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=>$colors[$color],
-style=>'arc',
-start=>90,
-extent=>-$actual_angle,
-tags=>$myorfs{$key}[1]);

What I have so far to draw lines:

$xstart = (cos($current_arclength)*$radius+$xcenter) /10;
$ystart = (sin($current_arclength)*$radius+$ycenter) /10;
$canvas->createLine($xstart+$xcenter,
$ystart+$ycenter,
$xstart+($xstart*0.01)+$xcenter,
$ystart+($ystart*0.01)+$ycenter);

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**********@bayer.com
Jul 18 '05 #1
2 2142
On Thu, 04 Sep 2003 07:55:18 -0700, Talon <ta*****@hotmail.com> (by way of Talon <ta*****@hotmail.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=>$colors[$color],
-style=>'arc',
-start=>90,
-extent=>-$actual_angle,
-tags=>$myorfs{$key}[1]);

What I have so far to draw lines:

$xstart = (cos($current_arclength)*$radius+$xcenter) /10;
$ystart = (sin($current_arclength)*$radius+$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($xstart+$xcenter,
$ystart+$ycenter, From above, xstart already has xcenter in it, so don't add it again. Same for ycenter. $xstart+($xstart*0.01)+$xcenter,
$ystart+($ystart*0.01)+$ycenter); 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_arclength)*$radius+$xcenter;
$ystart = sin($current_arclength)*$radius+$ycenter;

$canvas->createLine($xstart,
$ystart,
$xstart+ cos($current_arclength)*$tick_length,
$ystart+ sin($current_arclength)*$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**********@bayer.com


HTH

Regards,
Bengt Richter
Jul 18 '05 #2
> $xstart = (cos($current_arclength)*$radius+$xcenter) /10;
$ystart = (sin($current_arclength)*$radius+$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
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...
8
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
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...
0
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...
14
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...
0
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...
9
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...
7
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...
14
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 /...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.