Platform
Resources
Pricing
Sign in
Get started
David Mora
Passionate about viz & systems thinking. Stanford CS 2017
Workspace
Fork
Public
By
David Mora
Edited
Feb 17, 2023
Fork of
Rotating ellipse
Insert cell
Insert cell
Insert cell
function
getX
(
theta
)
{
return
a
*
Math
.
cos
(
alpha
)
*
Math
.
cos
(
theta
)
-
b
*
Math
.
sin
(
alpha
)
*
Math
.
sin
(
theta
)
}
Insert cell
function
getY
(
theta
)
{
return
b
*
Math
.
cos
(
alpha
)
*
Math
.
sin
(
theta
)
+
a
*
Math
.
sin
(
alpha
)
*
Math
.
cos
(
theta
)
-
translateY
}
Insert cell
viewof
theta
=
Inputs
.
range
(
[
0
,
100
]
,
{
label
:
"theta"
,
step
:
1
}
)
Insert cell
translateY
=
Math
.
sqrt
(
a
**
2
*
Math
.
sin
(
alpha
)
**
2
+
b
**
2
*
Math
.
cos
(
alpha
)
**
2
)
Insert cell
mutable
alpha
=
0
Insert cell
rotate
=
{
var
t
=
0
;
while
(
true
)
{
t
+=
.005
;
mutable
alpha
=
(
t
*
2
*
Math
.
PI
)
%
(
2
*
Math
.
PI
)
;
yield
mutable
alpha
;
}
}
Insert cell
points
=
[
0
,
Math
.
PI
/
2
,
Math
.
PI
,
(
3
/
2
)
*
Math
.
PI
,
2
*
Math
.
PI
]
.
map
(
theta
=>
[
getX
(
theta
)
,
getY
(
theta
)
]
)
Insert cell
morePoints
=
d3
.
range
(
0
,
Math
.
PI
*
2
,
.1
)
.
map
(
theta
=>
[
getX
(
theta
)
,
getY
(
theta
)
]
)
Insert cell
viewof
a
=
Inputs
.
range
(
[
0
,
100
]
,
{
label
:
"a"
,
step
:
1
}
)
Insert cell
viewof
b
=
Inputs
.
range
(
[
0
,
100
]
,
{
label
:
"b"
,
step
:
1
}
)
Insert cell
<
svg
width
=
"500"
height
=
"300"
>
<
g
>
<
line
x1
=
"0"
x2
=
"0"
y1
=
"-150"
y2
=
"150"
/>
<
line
x1
=
"-250"
x2
=
"250"
y1
=
"0"
y2
=
"0"
/>
<!-- ${morePoints.map(([x, y]) =>
svg`<circle r="2" cx="${x}" cy="${y}"/>`
)} -->
${points.map(([x, y]) =>
svg`
<
circle
class
=
"sound"
r
=
"5"
cx
=
"${x}"
cy
=
"${y}"
/>
`
)}
</g>
</svg>
Insert cell
<
style
>
svg
{
background
:
#fcf3f2
;
}
g
{
transform
:
translate
(
50
%
,
50
%
)
;
}
circle
{
fill
:
black
;
}
circle
.
sound
{
fill
:
red
;
}
line
{
stroke
:
black
;
stroke-width
:
2
px
;
}
</
style
>
Insert cell
d3
=
require
(
"d3@5"
,
"d3-array@2"
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getX
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getY
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
theta
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
translateY
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
alpha
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rotate
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
points
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
morePoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
a
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
b
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML