►
From YouTube: BHTMS - Cyclic Scalar Encoder
Description
Broadcasted live on Twitch -- Watch live at https://www.twitch.tv/rhyolight_
A
All
right,
Jeremy's,
gonna
bail,
that's
cool,
don't
worry
about
it.
You
can
come
back,
listen
another
time,
we're
building
a
react,
app
whoo
and
if
you've
watched
me,
you
know
what
I
feel
about
react
right
now.
Actually,
it's
working
fine
I'm,
pretty
happy
with
where
we're
at
here.
So
let's
take
a
look
at
it.
Real
quick!
So
here
is
the
web
app.
We
are
constructing
we're
working
on
encoding
numbers
here,
and
so
this
is
our
page.
We're
not
open
up
the
debugger,
and
here
is
where
we
are
at.
This
is
a
tutorial
documentation.
A
It's
interactive
documentation
that
is
going
to
explain
how
encoding
numbers
into
binary
representations
works.
This
is
what
you
have
to
do
to
get
your
data
into
a
format
that
your
brain
can
comprehend.
At
least
our
simulations
of
brain
matter
can
comprehend
thanks.
They
just
go
for
for
joinin.
It's
you
need
to
go
to
bed,
it's
good,
get
to
sleep.
You
can
always
watch
later.
I
put
all
this
stuff
on
YouTube
we've
been
going
for
three
hours
now:
Wow
okay,
so
this
is
complete
with
code.
A
Examples
like
here's
an
example
of
a
very,
very
simple
encoder,
and
then
here
I
show
examples
of
it
working
you
know,
and,
and
so
I've
got
a
bunch
of
diagrams.
That's
what
we're
doing
is
we're
converting
these
diagrams
I've
already
written
into
react
components
so
we're
creating
a
react,
application
and
so
cool
thing
about
this.
A
Is
it's
all
going
to
be
reactive,
in
that
you
can
change
the
parameters
of
things
and
all
of
the
diagrams
update,
so
we're
gonna
have
a
bunch
of
ways
for
the
user
to
tune
things
and
to
see
the
diagrams
change
in
real
time.
Here's
another
one
where
we're
encoding
using
a
resolution
instead
of
a
minute,
a
Mac.
So
that's
a
concept
of
scalar
encoding
and
now
here
we
are
at
these
cyclic
encoders.
So
here's
this
is
where
we
left
off
in
my
last
BH
TMS
stream.
A
A
A
A
A
A
Well,
just
call
you
I,
like
calling
you
Dee
duck.
It's
like
a
superhero
name,
all
right,
so
I'm,
just
trying
to
figure
out
where
I
was
I
was
partially
through.
This
I'm
gonna
commit
this,
as
it
is
right
now
to
the
branch,
knowing
that
it's
it's
not
everything's,
working
well,
I
mean
it's
nothing's
broken,
but
I
haven't
implemented
everything
yet
so,
let's
just
add
these
components
and
pages,
the
old
source
shouldn't
be
added
toggle
cycle.
Never
okay,.
A
A
Close
that
this
is
the
this
fancy
cyclic
encoder
display
is
just
what
we
were
using
as
a
reference,
because
that
this
has
the
code.
I
was
stealing
on
that
code,
yeah
cyclic
encoder,
so
so,
once
we
get
this
working
we're
going
to
see
if
there
is
an
opportunity
to
create
an
abstract
class
for
our
d3
components,
because
we're
gonna
have
to
react
diagrams
that
our
d3
components,
it's
quick,
quick
overview
here.
A
Everything
starts
with
pages
index,
that's
the
main
page,
and
these
are
all
pages
and
we're
working
on
encoder
encoding
numbers,
that's
the
page
or
working
on.
So
that's
that's.
What
we're
looking
at
here
is
an
encoding
numbers
page,
and
so
we've
got
pages
here
and
react.
Components
are
in
this
components.
A
Folder,
so
I
have
a
couple
of
generic
components
like
a
layout,
a
header
and
this
code,
syntax
tool
that
someone
else
helped
me
with,
and
the
these
are
our
inputs
like
there's
a
number
input,
the
thing
that
I
clicked
up
and
down
something
David
helped
me
with
the
scrubber
I'm
not
currently
using,
but
I
might
come
back
to
on
this
toggle
button.
The
diagrams
are
all
here
and
the
diagrams
thing,
and
currently
we've
got
simple
scalar
encoder,
which
is
basically
all
of
the
scalar
coders.
A
A
So
we're
now
we're
working
on
basically
our
second,
our
our
second
diagram
class
and
once
we
get
it
into
place
and
it's
working
we'll
look
at
potentially
pulling
an
abstract
based
class
out
of
them
that
perhaps
deals
with
d3
directly.
Something
like
that
we'll
see.
If
we
need
to
do
that,
you
don't
want
to
have
hazard
lis,
create
abstract
classes,
but
you
don't
want
to
repeat
too
much
code
either.
Okay,
so.
B
A
I
believe
isn't
this
street
sells
yeah
I
change
the
street,
so
yeah,
here's
the
steer
in
the
circles
and
this
bit
all
that
I
that
I
copied
out
is
creating
a
data
array
that
represents
the
state
of
each
circle
as
it
as
it
moves,
and
so
we're
not
quite
doing
that.
Yet
right
now
we're
just
sending
the
raw
and
coding
in
and
that's
what
we're
using
to
create
the
circles.
A
A
It's
going
to
have
an
inline
function
here.
I,
don't
think
I
need
this
right.
Let's
try
and
do
this
all
like
harmonic
and
a
harmony
way
we're
also
going
to
have
access
to
D
and
I
here
D
is
the
data
point
that's
going
to
contain
the
bit
CX
and
CY
and
I
is
going
to
be
the
index
of
the
data
point
which
I
don't
I'm,
not
sure
we're
going
to
need.
A
So
so
we're
essentially
saying
if
the
displaced
state
is
a
circle,
we're
gonna
calculate
where
that
x
value
is
based
on
circle
math.
If
it's
a
line,
we're
gonna,
do
it
based
on
linear
math.
Let's
see
what
happens,
everything
broke,
okay,
so
encoding
is
not
defined.
That's
just
because
I
needed
this
I
just
need
this
dot
encoding
map
and
then
we're
not
sending
the
distant
coding
and
we're
just
gonna.
Send
this
data
array,
so
I
forgot
to
do
that.
I
think!
That's
right!
A
A
A
Go
I
went
through
this
phase
of
saying
let
this
equal
blah,
comma,
the
sequel,
blah,
comma,
the
sequel,
a
comma
and
now
I
wish
I'd.
Never
would
have
done
it
because
every
time
I
come
across
it.
It
makes
it
hard
to
comment
lines
out.
So
I
just
want
to
be
able
to
do
this.
I
don't
need
not
don't
need
that
it
don't
need
that
whoops
do
I
need
this
yeah.
B
A
A
A
A
A
Or
am
I
getting
it
it's
what
we
should
be
setting
it's
what
the
toggle
button
is
set,
so
this
may
be
new
code
that
we
need
to
put
in
place
because
it's
what
it's,
how
are
we
creating
it?
Let's
take
a
look.
Click
get
out
of
this
old
source
and
the
page
numbers
when
we
create
this
cyclic
encoder
over
here
or
cyclic,
a
corner
we're
sending
it
in
the
display
state,
so
should
be
a
prop
I'm.
Just
checking
double
checking
here
so
so
displays
state.
This
is
gonna.
Be
this
stop
prop
stop
this
play
state.
A
A
Same
thing,
I
think
182
I
think
I
just
need
to
replace.
Oh
yeah
yeah.
That's
that's
it!
Thank
you!
That's
even
better
I!
Don't
even
think
I
need
this.
So
I'm
gonna
take
that
out
business.
I
love
how
you
could
just
change
the
code.
It's
amazing
is
there
anything
else.
That's
coming
from
props,
no
okay,
so
that
displays
states
needs
to
be
what
was
it?
182,
hey,
Jasper,
thanks
for
hosting
169.
A
A
A
A
That's
the
center
of
the
larger
circle
that
we're
gonna
be
wrapping
the
line
around.
So
let
me
click
here
yeah.
So
this
this
line
here
is
gonna.
Have
is
gonna,
be
as
displayed
as
a
circle
down
here
in
the
center's
right
here
when
we
click
this,
not
quite
we're
almost
there
157
radius
and
our
radius
is
passed
in.
A
A
There
we
go
Hey,
look
at
that
boom-boom
boom-boom
on
one
of
them.
That's
successful!
I
like
that!
Alright,
so
we
got
something
working
here.
So
does
everybody
understand
what
we
did
there?
We
all
we're
doing
is
instead
of
passing
the
encoder
data
directly
in
we're
gonna,
transform
it
a
little
bit
and
we're
gonna
calculate
our
CX
and
CY
as
we
as
we
pass
through
and
in
one
aspect.
A
If
it's
a
circle,
we're
gonna
do
circle,
math
to
figure
out
what
the
CX
and
CY
is
of
each
and
if
it's
not
we'll
just
do
the
linear
math.
So
it's
pretty
simple.
What
gets
tricky
is
when
you
want
to
do
this
transition.
So,
first
of
all,
let's
place
this
in
the
right
spot,
because
it's
first
of
all
the
radius
is
a
little
bit
too
big.
So
let's
go
check
the
radius
here
and
let's,
let's
make
it
a
little
smaller.
A
A
That's
probably
easy
enough
to
do
well,
we'll
just
bump
them
both
down
by
this.
What
is
a
ratio
to
top
size
divided
by
20?
It's
not
really
what
I
want
there
I,
don't
think.
So
what
happens
if
I
do
this?
Okay,
it
moves
it
down.
That's
not
really
what
I
want!
Why
can't
it
just
be
a
padding,
let's
just
say
a
top
cell
padding
and
we'll
just
give
it
I,
don't
know
100
pixels
for
the
moment
and
then
we'll
get
rid
of
this
ratio
to
the
top
thing
we're
just
going
to
make.
A
A
A
A
A
A
Where
are
we
here,
cyclic
scalar
yeah?
Let's,
let's
write
after
it
does
this:
let's
see
what
that
data
object
looks
like.
Is
it
not
gonna,
not
gonna.
Do
it
there
we
go
okay,
so
the
data
object
bits:
zero,
zero,
zero,
zero,
zero,
all
zeros
there's
a
few
ones?
Okay!
So
that's
so
it's
done
that
properly
so
right
here
when
we're
deciding
how
to
fill
it,
we
should
also
break
Oh.
A
A
Cuz
is
what
on
what
do
you
mean?
Oh,
oh
you
mean.
So
this
is
an
SVG
fill
color
and
so
I'm,
basically
saying
if
it's
on,
if
T
is
on,
oh
I,
see
what
it
is.
D
is
now
I
used
to
depend.
D
has
it's
just
stop
it,
so
all
I
need
to
do
is
say
dot
bit.
That's
it!
That's
all!
Okay!
So
that's
easy!
That
was
just
my
I
was
transitioning
from
one
to
the
other.
There.
B
A
Okay,
now
so,
if
I
do
circle,
this
should
still
work.
Let
me
turn
this
off,
because
it
updates
a
whole
lot
better.
There.
We
go
look
at
that
beautiful
so,
but
it
is
apparently
bounded
and
it
shouldn't
be
it
should
it
should
roll
over
so
do
I
have
to.
A
B
A
Am
using
a
cyclic
encoder,
so
that's
what
I
need
to
do?
I
need
to
use
the
cyclic
encoder,
it's
a!
So.
If
you
look
here
in
the
page,
there's
a
link
to
the
cyclic
code.
It's
super
simple.
It's
just
doing
a
little
different
application
of
the
bit
mask
so
I
think.
That's
all
what
we
need
to
do
is
in
our
cyclic
encoder.
We
use
cyclic,
encoder
I'm,
hoping
that's
a
cyclic
encoder
and
where
I
created
that
decoder,
which
was
I,
believe.
A
A
Perfectly
and
so
we
get
to
the
end
and
it
loops
around
the
front.
That's
what
the
cyclic
decoder
does
essentially
same
thing
here
you
get
to
the
end
and
a
loops
around
the
front.
Alright,
that
looks
nice.
So
let's
do
the
transitionary
parts
now
so
now
we're
going
to
do
if
so
so,
here's
a
tricky
bit
because
we
have
to
create
an
animation
context
or
an
animation
handle,
and
when
someone
clicks
on
the
toggle,
let's
go
back
to
about
this
one
coding
numbers.
A
A
A
A
A
Yeah
this
this
is
this
is
what
will
update
whenever
someone
presses
the
button.
The
thing
I'm
wondering
about
is
right.
Now
the
button
only
button
has
two
states
line
or
circle
and
I
need
to
have
these
states
that
are
aligned
a
circle
and
circle
to
line
and
I
need
to
know
how
long
the
animation
is.
That's
how
you
do
the
calculations
and
the
data
array
so
what's
going
to
get
here,
is
just
line
or
circle,
and
so
I
need
to
check
if.
A
Like
I've
got
similar
code
in
here
that
does
this
type
of
checking
and
to
places
like
e,
so
we
need
to
so
I'm,
depending
on
a
display
state
being
line
to
circle
or
not
I'm
wondering
what
the
best
way
to
do
this
is
we
could
we
could
set
the
display
state
from
the
outside
and
handle
the
animation
there,
but
I
don't
think
that's
the
right
thing
to
do.
I
think
the
display
state
gets
set
on
this
component.
It
should
kick
off
an
animation,
create
an
animation
handle
for
it
and
then
transition
to
the
next
state.
A
A
A
A
B
A
B
A
A
Research
meeting
was
pretty
complicated.
It
was
hard
to
keep
up
okay.
Similarly,
we
have
this
animate
value,
so
we'll
create
a
function
right
that
animates
similar
to
this.
Now
this
one
is
a
trigger.
So
if
this
doesn't
have,
this
is
going
to
be
a
trigger
like
this,
it's
just
going
to
be
a
you
can
just
make
it
a
function.
It
doesn't
have
to
return
a
function
so
we'll
create
something
that
and
we'll
do
something
similar
to
this
clearinterval
ba
ba
ba
ba
right.
A
A
A
A
A
B
A
A
A
From
the
outside,
let's
say:
I
wanted
to
I
wanted
to
transition
over
50
steps.
You
know
to
go
from
one
state
of
a
line
to
a
circle
as
soon
as
I
get
updated
to
a
line
here
and
component
that
did
update
I
know
it's
gonna
render,
but
now
I
need
to
kick
off
something
that
basically
Brett
is
going
to
rerender
every
50
steps,
so
I
need
to
perhaps
I,
don't
know,
I
don't
know.
A
A
A
A
Circle
two
lines
scale
Y
and
it
takes
this
transition.
What
is
this?
It's
just
a
scale,
it's
a
linear
scale
and
this
transition
right
all
right,
so
I'm
using
so
I'm
using
the
linear
interpolation
that
d3
does
to
to
to
identify
where,
in
the
transition
space
I
am
based
on
this.
This
transition
variable
so
I
need
to
keep
track
of.
So
when
someone
presses
that
button
and
I
get
an
update,
I'm
saying
okay
I'm
a
circle
now
I
need
to
be
a
line.
I
need
to
first
of
all
update
my
state
to
circle.
A
A
So
I
think
that's
close
I
think
what
I
was
just
saying,
close
I
just
have
to
at
least
that's
that's.
What
I,
how
I
did
would
do
it
with
d3
is
created,
treated
a
scale
that
helps
me
transition
circle
to
line
versus
line
to
circle,
and
these
are
different
only
because
well
they're
inverses
of
each
other.
Aren't.
B
A
A
So
I'm
not
sure
what
the
best
way
to
do
I
mean
it
seems
like
component
did.
Update
is
going
to
be
set
when
toggle
button
is
pressed,
but
all
this
other
state,
maybe
not
I,
mean
all
the
other
internal
state
because
we're
going
to
loop
through
a
whole
bunch
of
different
we're
going
to
transition
from
one
state
to
another.
So
there's
going
to
be
a
bunch
of
states
line
to
circle
circle,
the
line
whatever
and
each
one
of
those
has
to
render
to
get
where
we're
going
so.
A
A
A
A
B
A
A
All
I
really
think
I
need,
and,
and
this
this
seems
familiar,
this
is
what
I
generally.
This
is
what
I
did
in
the
last
one,
but
but
I'm
not
manipulating
the
data
array.
Here,
that's
that's
the
thing
you
have
to
think
about,
and
this
component
did
update.
I'm,
not
manipulating
the
data
array.
The
data.
B
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A
It's
not
just
a
it's
going
to
be
line,
but
then
there's
also
going
to
be
and
if,
if
it's
a
line
and
this
dot
animation
handle
as
so,
so
if,
if
we're
animating
a
line,
so
let's
move
this.
Let's
move
this
here
that
work
think
so.
So
let's
do
this
first!
Oh,
that
was
awful
something
the
indentation
of
that
was
was
bad.
A
A
A
A
A
A
A
A
A
We
got
some
what
kind
of
clothes
okay
count
is
read.
Only
oh
yeah
I
can't
make
count
constant.
A
A
Update
displays
not
function
on
ad,
because
it's
just
update
right
component
tip,
update,
we're
gonna
call
this
stuff
update,
and
this
really
needs
to
be
else
right,
we're
gonna,
otherwise
we're
gonna
update.
We
don't
want
to
update
every
time
component
account,
or
else
this
would
happen
over
and
over.
No,
that's
not
true.
A
B
A
Render
output
render
output
cells,
it
is
yeah
here,
yeah
I
mean
I
I
want
to
write.
I.
Think
I
want
to
look
at
that.
That's
that's
good
I
want
it
to
look
at
the
because
it's
going
to
set
it
right
here
and
I'm
deciding
what
I'm,
what
type
of
how
I'm
going
to
show
the
circles
dependent
on
the
display
state
and
whether
the
animation
handles
set.
If
I
see
the
display
state
this
line
and
there's
an
animation
handle
it's
set.
I
know
I'm
going
from
line
to
circle.
Okay,.
A
Okay,
where
was
I?
What
was
the
break?
Oh
yeah
transition.
That's
what
I
just
updated,
I'm
gonna
Hugh's
animation
handles
one
of
the
conditions,
because
I
know,
if
there's
an
animation,
handle
that
I'm
transitioning
from
one
to
the
next,
because
I'm
going
to
clear
it
as
soon
as
the
transitions
over
so
I'm
going
to
use
the
state
as
the
original
state
the
display
state,
if
it's
a
there's
no
animation
handle
I,
know
I'm
in
that
state.
If
there
is
one
of
no
I'm
moving
to
the
other
state.
A
A
B
A
A
Oh
yeah,
this
just
means
if
it's
changed.
Okay,
so
yes,
we're
gonna
go
into
this.
Okay,
I
have
not
rear-ended
yet,
and
so,
but
once
we
get
so
here's
the
thing
that
bothers
me
we're
gonna,
it's
gonna
update,
I,
don't
want
to
update.
Yet
all
right,
I
wanted
to
I
want
the
animation
to
update
it.
So
as
soon
as
we
go
here,
it
updates-
and
now
it
goes
circle.
I,
don't
want
a
circle.
A
So
that's
why
I
was
trying
to
put
that
update
elsewhere
and
then
you
said
no
and
I
thought
it
was
you,
but
I
think
it
might
have
been
your
son,
so
I'm
gonna
manually,
not
manually
but
I,
mean
I'm
gonna
call
update
here
and
I'm
gonna
call
update.
Oh
I
could
just
return
there,
you're
right,
I
hate
returning
within
functions,
though
I
mean
within
conditions.
I
really
try.
I
would
prefer
to
try
and
return
at
the
end
of
the
method,
but
so
this
will
work
too
right.
A
It's
just
a
little
bit
more
explicit
when
you
return
in
the
middle
of
a
condition,
if
you're
not
within
that
condition.
Reading
it
you're
not
aware
of
that
context.
So
I
try
not
to
return
from
within
conditions.
I'll
I'll
do
something
in
the
conditions
and
then
use
that
state
to
make
a
decision
later.
So
in
this
case,
each
one
of
these.
This
is
going
to
update
it
if
the
prop
changed
or
value
changed,
and
this
is
going
to
animate
an
update
if
the
display
state
change.
A
A
B
A
It
but
I
think
for
this
one:
no
okay:
where
are
we
at
so
so
we're
in
the
animation?
Now
we're
going
to
calculate
the
transition?
We
should
start
at
zero.
The
next
one
should
be
one:
okay,
we're
not
cutting
we're
just
going
to
update
I
didn't
do
it
doesn't
do
it,
okay,
something's
wrong,
so
the
transition
is
being
updated
right
so
and
the
transition
is
a
number
from
zero
to
one.
So
let's
go
up
here
and
figure
out.
A
B
A
A
A
A
Make
sense
it
doesn't
make
sense.
Does
it
right
here
is
where
the
display
states
should
be
oh
I'm,
gonna.
Let
react
manage
this
state,
so
I'm
not
gonna.
Do
this
well,
let
react
manage
the
state,
and
so
now
now
bear
with
me
here
down
here.
If
so,
if
we're
in
a
circle,
we
do
a
circle
if
we're
in
a
circle,
and
actually
this
is
now
gonna-
be
line.
No.
A
If,
if
we're
moving
to
a
circle,
that's
what
this
is
I,
don't
think
so
wait.
Did
you
just
write
that
circles?
This
also
need
a
circle
and
animation
handle
no,
no,
no
see
I,
think
you're,
I
think
Dave,
you're
you're,
just
maybe
you're,
not
understanding
the
way
d3
is
working
here.
So
this
is
going
to
happen
on
every
R
animation.
This.
A
A
So,
if
we're
a
circle,
it's
easy.
If
we're
going
to
a
circle,
we're
animating
to
a
circle,
it's
a
little
harder
right,
so
this
animation
happen
for
circle
to
line
and
line
a
circle.
Yeah,
that's
the
idea!
So
I'll
have
like
this
bit
here
for
one
in
this
bit
here
for
the
other.
That's
it
once
I
get
these
little
things
hooked
up
it
should
it
should
work.
So
this
one's
going
to
be
lying
to
circle
and
that's
the
thing
yeah
line
line
to
circle,
yeah.
A
A
Okay,
okay,
making
progress,
linear
scales,
not
defined,
that's
because
I
I
haven't
I
forgot
to
create
it.
I
think.
There's
this
linear
scale,
which
I've
commented
out
somewhere.
This
is
this,
is
one
I've
already
created?
It's
called
value
to
scale.
What
is
it
called?
It's
an
orient
d3
here
it
is
Val
to
screen.
This
is
the
one
I
want.
A
A
A
I
took
that
out
and
I
replaced
it
with
just
a
top
cell,
padding
I,
think
I'm,
not
sure,
that's
yeah,
that's
a
top
cell
padding
I'm,
not
sure.
If
this
is
gonna
work,
it
worked
check
it
out.
All
right,
I
mean
there's
a
little
bug
there,
but
that's
what
I'm
talking
about
didn't
quite
work,
but
it
worked
well
enough.
The
cheer!
Oh!
We
got
some
problems,
but
it
worked
once
it
worked
once
the
first
time.
A
Okay,
but
we
can.
We
can
move
all
along
with
this,
so
the
rest
of
the
issues
you're,
probably
just
because
we
haven't
hooked
up
the
others
like
transitions
and
everything
yeah
push
to
production.
Okay,
so
I
will
commit
this.
It's
buggy
it's
buggy,
but
I
will
commit
it
right
now
and
I'm
gonna
take
off
because
I'm
gonna
work
a
little
bit
on
this
offline
and
I
have
some
other
things
that
I
need
to
do
with
the
new
mental
anomaly
benchmark.
A
A
A
A
Okay,
animation
handle
so
I'm
gonna
I'm
gonna
delete
this
stuff
because
I'm
think
we
pushed
through
it
I
think
the
rest
is
gonna,
be
simple.
That's
the
hard
part
getting
that
didn't
that
first
little
spike
through
and
seeing
something
work
is
the
hard
part,
but
I
think
we're
on
the
right
track
here.