Comments (8)
It is opposite to the current implementation, which uses Math.abs(startAngle - endAngle) as the length of the arc.
That makes sense being the current implementation hence the incorrect result (from my point of view). Following the idea of "suggesting direction" plus the adjustedStartAngle the length of the arc would be computed using endAngle - startAngle
and it would always be positive (in the clockwise direction).
this would create potentially disastrous visual instability if the numbers originate from an instable formula—like, for example going from startAngle = 0 to endAngle = .6 + .3 - .9 (which is a negative number -1.1102230246251565e-16).
The core problem in that scenario is the unstable formula which is outside of the d3-shape, hence the correction should be applied outside. The developer will have a hard time figuring it out since the current implementation is correcting/masking it.
from d3-shape.
I don't think this case is documented or tested.
from d3-shape.
In the documentation of arc.startAngle and arc.endAngle its stated:
The angle is specified in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
So if you start at Math.PI and end at Math.PI / 2 one would expect the arc to take the long way (an arc with 270 degrees). The short way would be if you start at Math.PI / 2 and end at Math.PI (an arc with 90 degrees).
TL;DR: its already documented. The implementation is producing incorrect results.
from d3-shape.
I’m pretty sure it’s intended to be this way (so that it doesn’t matter which value is the startAngle or the endAngle; the arc is not directional). If you want the larger sector, I expect you need to do this:
arc({
innerRadius: 0,
outerRadius: 100,
startAngle: Math.PI,
endAngle: 5 * Math.PI / 2
});
from d3-shape.
If the intended way if for the start and end angles to be interchangeable than it should be documented, the words start and end suggest direction.
from d3-shape.
Speaking of "suggesting direction", I read "positive angles proceeding clockwise" as implying "negative angles proceeding anticlockwise" (which is conform to what the implementation does); otherwise, the sentence would have been "all angles proceeding clockwise". But I understand how you can read that sentence as meaning only the position and not the span.
If there was a debate whether the implementation should be changed, I'd be strongly against the change, if only because it would make the arc generator unstable when a computation returns a very small span—going from 1e-17 to -1e-17 would suddenly make the arc go from a sliver to a full circle.
from d3-shape.
But I understand how you can read that sentence as meaning only the position and not the span.
Not sure If I understand. Starting at π and ending at π/2 will have a positive angle span of 3π/2. The reverse will have a positive angle span of π/2.
when a computation returns a very small span—going from 1e-17 to -1e-17 would suddenly make the arc go from a sliver to a full circle.
Starting at 1e-17 and ending at -1e-17 would produce a full circle. However starting at -1e-17 and ending at 1e-17 would still produce a sliver. Both are still consistent with the "suggesting direction" idea.
from d3-shape.
Starting at π and ending at π/2 will have a positive angle span of 3π/2. The reverse will have a positive angle span of π/2.
To clarify, that's the convention you're proposing, which is to go from point(startAngle) to point(endAngle) in the clockwise direction. It is opposite to the current implementation, which uses Math.abs(startAngle - endAngle) as the length of the arc.
Starting at 1e-17 and ending at -1e-17 would produce a full circle.
Exactly: my comment is that this would create potentially disastrous visual instability if the numbers originate from an instable formula—like, for example going from startAngle = 0 to endAngle = .6 + .3 - .9 (which is a negative number -1.1102230246251565e-16).
from d3-shape.
Related Issues (20)
- Arc - Inconsistent error notification when invoked via fluent function calls vs invoking with data HOT 1
- Dynamic smoothing interpolation HOT 2
- Possible typing issue or a missing example (How to write a custom accessor?) HOT 1
- lineGenerator fail
- es5 to es6+ syntax? HOT 1
- The pie arguments problem HOT 1
- the BumpRadial curve only works with two-point lines
- Needs connection to me not fast enough!
- How does Catmull Rom work with a Bézier curve? HOT 2
- The types for Arc are incorrect HOT 1
- Unexpected arcs when corner radius is nonzero HOT 1
- curveBumpX creates a circle in Chrome if applied to a straight line. HOT 2
- How to add pointer effect to the shape? HOT 1
- running tests with d3-shape HOT 1
- Configurable precision for generated path data HOT 1
- startPadAngle and endPadAngle HOT 4
- Curve Natural gets outside the svg HOT 1
- add optional angle radius parameter in curbeBezier `curveStep` curves HOT 4
- option for arc's curve precision
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-shape.