I really confused with parameters StartAngle and EndAngle, how it works.
For example I need to draw arc from -30 to 30.
I tried:
(-30,30),
(330,30),
(30,330),
(330,390),
(-30,390)
etc.
But every one draws full circle minus desired (-30,30) sector.
While piesclice(...330,360...) and piesclice(...360,390) works as I need, giving together desired (-30,30) sector.
However I want proper algorithm of work with pieslice to draw arcs <180 and >180 in desired direction.
No manual expanded on this subject.
Please help me.
It can draw sector from 0 to 30, but when I try draw from -30 to 30
it draws full circle minus sector i.e. more than 180 degrees arc
I tried to pass 330, 390
Related
I'm totally a beginner in Trigonometry so my question may seem so trivial for many of you.
If my understanding is correct, based on the trigonometry a degree is defined by dividing the circumference of a circle into 360 equals parts so that each of those parts is called a degree. Now imagine that you open a circle and roll it on the table to form a simple straight segment (as if you actually drew a segment on a piece of paper using a ruler). You would then have a straight segment divided by 360 equal parts. What would be the distance between each degree ( = each division) in terms of millimetre on that segment? The reason that I ask this question is that I was looking to a protractor as you can see in the picture below:
The bottom of this protractor is an ordinary ruler and above of that we can see the measures of the degrees from 0 to 180. When I compare visually the measures on the ruler on the bottom with the degrees measures on the top of the protractor, it seems that they are the same and each degree has a distance of 1 millimetre from the next or previous degree. Is this true? Sorry if the question seems somewhat trivial for many of you but I'm completely a beginner in the field and I just try to understand how these units were actually defined.
The circumference of a circle is pi * the diameter, where pi is about 3.14159.
The diameter of your protractor looks to be about 120mm, so the circumference would be about 377 mm. Dividing by 360, each degree would be 1.05 mm -- pretty close.
That's so close that I wouldn't be surprised at all if the diameter of your protractor was actually designed to be 114.6mm, just to space the degree marks out by exactly 1mm.
I have written a program that arranges stars stars into polyhedra, for example tetrahedron. here is a mutant tetrahedron, i dont know why the sides dont line up, and how to correct it. please help.
I had to rotate the stars by +/- 90' and it lined up symetrically. i was confused because the points of the triads were touching, and it gave the illusion that only half the sides could be aligned. actually, by rotating all sides equally by +/- 30 or by 90 degrees produced 2 different classes of symmetrical shapes.
Let me start out by saying my end goal is something that resembles the image below. It has 36 circles in each of the rings, spaced such that each dot is mid way between two dots in the circle inside of it
I figured out I could use a stroke-dasharray with really small lengths (.001 in my case) and stroke-linecap="round" to make the borders circular dots. The way I have it set up now each circle has a radius 5 bigger than the last and an incremented percentage for the stroke-dasharray. Here is my jsFiddle. Currently My inner most ring only has 21 dots and my outermost ring has 29 dots
How can I get the same number of dots per circle? Is there a mathematical way to do this or an attribute that I am unaware of? What can be done to evenly space out the circles using the whole circumference equally (instead of having some on the right side of the what I perceive as the x-axis)?
It seems to me that I would have to simply guess and check with the values in order to get it the way I want but I would love to be proven wrong. The stroke-dasharray documentation on Mozilla and W3C aren't very useful
Since you're using stroke-dasharray on a circle, you need to use π (3.14159265) to get even spacing.
Given the formula spacing = (radius × 2) × 3.14159265 ÷ numberOfCircles, your SVG circle would be <circle r="{radius}" stroke-dasharray="0.001, {spacing}"/>.
To achieve the spiral effect, apply a rotation of 360 ÷ numberOfCircles ÷ 2 to every other ring. I used CSS to accomplish this, circle:nth-child(even) being the selector and -webkit-transform: rotate( {rotation} ); being the style applied.
I forked your JSFiddle1.
1 Note that the spiral is visible in webkit browsers only. Also, the rings are slightly misaligned on the right for, to my knowledge, unknown reasons.
I'm working on a small webapp in which I need to rotate shapes. I
would like to achieve this by grabbing a point on a circle and
dragging it around to rotate the image.
Here's a quick illustration to help explain things:
My main circle can be dragged anywhere on the canvas. I know it's
radius (r) and where 12 o'clock (p0) will always be (cx, cy - r). What
I need to know is what degree p1 will be (0-360º) so I can rotate the
contents of the main circle accordingly with Raphael.rotate().
I've run through a bunch of different JavaScript formulations to find this (example), but none seem to give me values between 0-360 and my basic math skills
are woefully deficient.
The Color Picker demo (sliding the cursor along the ring on the right) has the behavior I want, but even after poring over the source code I can't seem to replicate it accurately.
Anything to point me in the correct direction would be appreciated.
// Angle between the center of the circle and p1,
// measured in degrees counter-clockwise from the positive X axis (horizontal)
( Math.atan2(p1.y-cy,p1.x-cx) * 180/Math.PI + 360 ) % 360
The angle between the center of the circle and p0 will always be +90°. See Math.atan2 for more details.
I am writing a program (.net) to create a stadium style layout and need to determine the angle of rotation for each polygon compared to the horizontal.
This is so i can construct the contents of the polygon and also rotate this correctly to fit inside.
Given the below image as an example to simulate each variant of the facing direction (indicated by the red line) how could i determine the the rotation angle needed to get the shape to have the red line on top as is already shown by shape 5.
http://i40.tinypic.com/16ifhoo.gif
I have found logic to determine the angle of the points that make up the red line, but I also need to know the rotation to get it back to horizontal.
I'm not sure if i need some central reference point for all polygons to help.
How could I best solve this?
If you know the angle of the red line for some polygon (a, say), then the polygon is on one side or other of that line. So:
Use the average colour of some pixels near the line on both sides to determine which is the case.
If the polygon is above the line, the rotation angle is 180+a.
If the polygon is below the line, the rotation is a.
where above and below correspond to the smaller-angle side and larger-angle sides of the line according to how you measure a.
I would try to calculate the normal vectors on each red line (eg. 0 degrees for polygon 5, 45 degrees for 4, 90 degrees for 3, etc.) and then the angle you need to rotate that normal - and thus the matching polygon - so that the normal "points up" should be very simple.
Unfortunately I don't have the needed formulae available for you off the top of my head, but Googling "normal vector" and/or searching for it on Wikipedia should get you started just fine, I think. Possibly in the direction of the so called 'cross product'.
No central reference point for all polygons should be needed for this (normal direction is not related to absolute coordinates).
sin, cos, tan functions allow you to convert from triangle edge ratio to degrees.
Imagine, one end of red line is at (x1,y1) and other end is at (x2,y2). You can treat red line as hipotenuse of rectangular triangle and use arctan to get degrees.
Ratio between catheti is (x2-x1) / (y2 - y1). Rotation of red line then is arctan((x2-x1) / (y2 - y1)). Watch out for situations when y1-y1 is 0!
Let's try one example from your picture, polygon 6 with coords (55, 65) and (65, 55). Type in google: "arctan((65-55)/(55-65)) in degrees"