Visitar URL original
docs: reorganize polar examples · mauriciopoppe/function-plot@c48f2e8 · GitHub
Skip to content

Commit c48f2e8

Browse files
committed
docs: reorganize polar examples
1 parent 3203c1f commit c48f2e8

2 files changed

Lines changed: 54 additions & 63 deletions

File tree

‎site/js/site.js‎

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,30 @@ $(document).on('markupLoaded', function () {
131131
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
132132
})
133133

134+
/**
135+
* ### Polar coordinate grid
136+
*
137+
* Polar equations use Cartesian axes by default. Set `coordinateSystem: 'polar'`
138+
* to draw a polar grid with equal x/y units instead. `polar.grid` defaults to
139+
* `true`, while angular labels are opt-in with `polar.angularLabels: true`.
140+
* Labels use radians by default; `angleUnit: 'degrees'` changes their format.
141+
*/
142+
functionPlot({
143+
target: '#polar-grid',
144+
coordinateSystem: 'polar',
145+
polar: {
146+
radiusDomain: [0, 3],
147+
angularLabels: true
148+
},
149+
data: [
150+
{
151+
r: '2 * sin(4 * theta)',
152+
fnType: 'polar',
153+
graphType: 'polyline'
154+
}
155+
]
156+
})
157+
134158
/**
135159
* ### Domain
136160
*
@@ -772,6 +796,11 @@ $(document).on('markupLoaded', function () {
772796
*/
773797
functionPlot({
774798
target: '#polar-circle',
799+
coordinateSystem: 'polar',
800+
polar: {
801+
radiusDomain: [0, 3],
802+
angularLabels: true
803+
},
775804
yAxis: { domain: [-1.897959183, 1.897959183] },
776805
xAxis: { domain: [-3, 3] },
777806
data: [
@@ -788,52 +817,6 @@ $(document).on('markupLoaded', function () {
788817
]
789818
})
790819

791-
/**
792-
* ### Polar equations <br /> <div class="small">Polar rose</div>
793-
*
794-
* Rendering the equation of the polar rose
795-
*
796-
* $$
797-
* r = 2 sin(4 \theta)
798-
* $$
799-
*/
800-
functionPlot({
801-
target: '#polar-complex',
802-
yAxis: { domain: [-1.897959183, 1.897959183] },
803-
xAxis: { domain: [-3, 3] },
804-
data: [
805-
{
806-
r: '2 * sin(4 theta)',
807-
fnType: 'polar',
808-
graphType: 'polyline'
809-
}
810-
]
811-
})
812-
813-
/**
814-
* ### Polar coordinate grid
815-
*
816-
* Polar equations use Cartesian axes by default. Set `coordinateSystem: 'polar'`
817-
* to draw a polar grid with equal x/y units instead. `polar.grid` defaults to
818-
* `true`, while angular labels are opt-in with `polar.angularLabels: true`.
819-
* Labels use radians by default; `angleUnit: 'degrees'` changes their format.
820-
*/
821-
functionPlot({
822-
target: '#polar-grid',
823-
coordinateSystem: 'polar',
824-
polar: {
825-
radiusDomain: [0, 3],
826-
angularLabels: true
827-
},
828-
data: [
829-
{
830-
r: '2 * sin(4 * theta)',
831-
fnType: 'polar',
832-
graphType: 'polyline'
833-
}
834-
]
835-
})
836-
837820
/**
838821
* ### Implicit functions
839822
*

‎site/partials/examples.html‎

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,25 @@
5959
},
6060
grid: true,
6161
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
62-
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="grid" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Domain</h3>
62+
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="grid" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Polar coordinate grid</h3>
63+
<p>Polar equations use Cartesian axes by default. Set <code>coordinateSystem: 'polar'</code>
64+
to draw a polar grid with equal x/y units instead. <code>polar.grid</code> defaults to
65+
<code>true</code>, while angular labels are opt-in with <code>polar.angularLabels: true</code>.
66+
Labels use radians by default; <code>angleUnit: 'degrees'</code> changes their format.</p></div><div class="code"><pre><code class="javascript">functionPlot({
67+
target: '#polar-grid',
68+
coordinateSystem: 'polar',
69+
polar: {
70+
radiusDomain: [0, 3],
71+
angularLabels: true
72+
},
73+
data: [
74+
{
75+
r: '2 * sin(4 * theta)',
76+
fnType: 'polar',
77+
graphType: 'polyline'
78+
}
79+
]
80+
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="polar-grid" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Domain</h3>
6381
<p>The domains of both axes can be changed with the following configurations:</p>
6482
<ul>
6583
<li><code>xDomain</code>, defaults to <code>[-7, 7]</code></li>
@@ -540,6 +558,11 @@
540558
instead of rectangles generated by the interval-arithmetic sampler set
541559
<code>graphType: 'polyline'</code> which uses the normal single point evaluation</p></div><div class="code"><pre><code class="javascript">functionPlot({
542560
target: '#polar-circle',
561+
coordinateSystem: 'polar',
562+
polar: {
563+
radiusDomain: [0, 3],
564+
angularLabels: true
565+
},
543566
yAxis: { domain: [-1.897959183, 1.897959183] },
544567
xAxis: { domain: [-3, 3] },
545568
data: [
@@ -554,22 +577,7 @@
554577
graphType: 'polyline'
555578
}
556579
]
557-
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="polar-circle" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Polar equations <div class="small">Polar rose</div></h3>
558-
<p>Rendering the equation of the polar rose</p>
559-
<p>$$
560-
r = 2 sin(4 \theta)
561-
$$</p></div><div class="code"><pre><code class="javascript">functionPlot({
562-
target: '#polar-complex',
563-
yAxis: { domain: [-1.897959183, 1.897959183] },
564-
xAxis: { domain: [-3, 3] },
565-
data: [
566-
{
567-
r: '2 * sin(4 theta)',
568-
fnType: 'polar',
569-
graphType: 'polyline'
570-
}
571-
]
572-
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="polar-complex" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Implicit functions</h3>
580+
})</code></pre></div></div><div class="col-md-6 center-block demos"><span id="polar-circle" class="graph"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Implicit functions</h3>
573581
<p>The equation of a circle of radius 1 $x^2 + y^2 = 1$ expressed in an explicit way is:</p>
574582
<p>$$
575583
y = \sqrt{1 - x^2} \quad and \quad y = -\sqrt{1 - x^2}

0 commit comments

Comments
 (0)