# 제네바 휠 간헐 회전 (Geneva drive indexing)

입력축의 핀이 네 개의 홈 중 하나에 들어가 출력 휠을 밀어냅니다. 홈을 빠져나오면 입력축이 계속 돌아도 출력 휠은 다음 맞물림까지 멈춥니다.

## 체험 방법

한 바퀴를 재생한 뒤 맞물림 45°와 정지 200°를 비교하세요. 정지 구간에서 슬라이더를 움직여도 출력 각도는 90°로 유지됩니다.

## 재현 기준

이 외접 4슬롯 모델은 입력 0~90°에서 출력이 0~90°로 움직이고 남은 270° 동안 정지합니다.

## 기기별 조작

- PC · 한 바퀴 재생을 누르거나 Tab으로 입력 슬라이더를 골라 방향키로 각도를 바꾸세요.
- iOS · 한 바퀴 재생을 누르고 입력 슬라이더를 끌어 핀이 홈에서 빠지는 순간을 찾으세요.
- Android · 한 바퀴 재생을 누르고 입력 슬라이더를 끌어 핀이 홈에서 빠지는 순간을 찾으세요.

## 적용할 때

영사기나 인덱싱 장치의 연속 회전과 간헐 회전을 비교하는 교육용 도해에 씁니다.

## 그대로 보낼 요청

> 네 개의 홈과 회전 핀이 보이는 제네바 구동을 그려줘. 핀이 홈 안을 지날 때 출력 휠이 사분의 일 회전하고, 나머지 구간에는 멈추는 모습을 두 각도와 함께 보여줘.

## 참고한 동작

[Cornell eCommons · Geneva Mechanisms](https://ecommons.cornell.edu/bitstream/handle/1813/57662/002_010.pdf?isAllowed=y&sequence=11)

## 독립 실행 코드

아래 전체 코드를 HTML로 저장해 브라우저에서 엽니다.

```html
<!doctype html>
<html lang="ko" data-motion-locales="inline">
<head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>한 칸씩 도는 제네바 휠</title>
<style>
*{box-sizing:border-box}
:root{font:15px/1.4 system-ui,"Malgun Gothic",sans-serif;color:#3a3947;background:#f3ede1;color-scheme:light;--accent:#503c67}
body{margin:0;padding:clamp(10px,3vw,26px);min-height:100svh;display:grid;align-content:center}
main{width:min(100%,740px);margin:auto}
header,.readout{display:flex;align-items:baseline;justify-content:space-between;gap:8px 18px;flex-wrap:wrap}
header{margin:0 0 9px}h1{margin:0;font-size:clamp(20px,4vw,33px);letter-spacing:-.05em;line-height:1.12}
header small{font:650 12px/1.3 ui-monospace,monospace}
figure{margin:0}canvas{display:block;width:100%;height:auto;aspect-ratio:700/250;border-radius:7px;background:#e4d5bc}
.readout{padding:6px 0;font:650 clamp(11px,1.8vw,14px)/1.35 ui-monospace,monospace}
.controls{display:flex;gap:6px 9px;align-items:center;flex-wrap:wrap;border-top:1px solid currentColor;padding-top:8px}
button{min-height:35px;padding:7px 12px;border:1px solid currentColor;background:transparent;color:inherit;border-radius:5px;cursor:pointer;font:650 13px/1.2 system-ui,sans-serif}
button:active,button[aria-pressed="true"]{color:white;background:var(--accent);border-color:var(--accent)}
button:focus-visible,input:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
label{display:flex;align-items:center;gap:7px;flex:1 1 124px;min-width:0;font-size:12px;font-weight:650}
label span{flex:none;white-space:nowrap}
input[type="range"]{accent-color:var(--accent);flex:1 1 70px;min-width:55px;width:auto;margin:0}
@media(max-width:450px){header small{font-size:10px}.readout{gap:3px 7px}button{min-height:36px;padding:6px 9px}.controls{gap:5px}.controls label{flex-basis:100%}}
</style></head>
<body><main><header><h1 data-t="title"></h1><small data-t="method"></small></header>
<figure><canvas id="board" width="700" height="250" role="img"></canvas>
<figcaption class="readout"><span id="status"></span><output id="reading"></output></figcaption></figure>
<div class="controls"><button id="turn" data-t="turn"></button><button id="drive" data-t="drive"></button><button id="hold" data-t="hold"></button><label><span data-t="input"></span><input id="angle" type="range" min="0" max="360" step="1" value="0"></label></div></main>
<script>
'use strict';
const words={
 "title": [
  "한 칸씩 도는 제네바 휠",
  "The indexing wheel",
  "La rueda intermitente",
  "间歇转动的槽轮"
 ],
 "method": [
  "네 홈 제네바 구동",
  "Four-slot Geneva drive",
  "Mecanismo de Ginebra",
  "四槽日内瓦机构"
 ],
 "description": [
  "입력 핀이 홈을 지나는 동안에만 회전하는 바퀴의 평면도",
  "Plan view of a slotted wheel that turns as a pin crosses its slot",
  "Vista en planta de una rueda que gira cuando el pasador recorre una ranura",
  "俯视槽轮，销进入径向槽后带动槽轮转动"
 ],
 "input": [
  "입력",
  "Input",
  "Entrada",
  "输入"
 ],
 "output": [
  "출력",
  "Output",
  "Salida",
  "输出"
 ],
 "engaged": [
  "홈 맞물림",
  "Pin engaged",
  "Pasador acoplado",
  "销已啮合"
 ],
 "dwell": [
  "정지 구간",
  "Dwell",
  "Reposo",
  "停歇"
 ],
 "turn": [
  "한 바퀴 재생",
  "Play one turn",
  "Reproducir una vuelta",
  "播放一周"
 ],
 "drive": [
  "맞물림 45°",
  "Engaged 45°",
  "Acople 45°",
  "啮合 45°"
 ],
 "hold": [
  "정지 200°",
  "Dwell 200°",
  "Reposo 200°",
  "停歇 200°"
 ]
};
const languages=["ko","en","es","zh-Hans"];
const params=new URLSearchParams(location.search);
const preferred=params.get('lang')||document.documentElement.lang;
const code=languages.includes(preferred)?preferred:'ko';
const tr=k=>words[k][languages.indexOf(code)];
const by=id=>document.getElementById(id);
document.documentElement.lang=code;
document.title=tr('title');
document.querySelectorAll('[data-t]').forEach(el=>el.textContent=tr(el.dataset.t));
const board=by('board'),ctx=board.getContext('2d');
board.setAttribute('aria-label',tr('description'));
const reduced=()=>params.get('reduce')==='1'||document.documentElement.classList.contains('motion-reduced')||matchMedia('(prefers-reduced-motion: reduce)').matches;
let animation=0;
function animate(from,to,duration,render){
  cancelAnimationFrame(animation);
  if(reduced()||from===to){render(to);return;}
  const start=performance.now();
  function frame(now){
    const fraction=Math.min(1,(now-start)/duration);
    render(from+(to-from)*fraction);
    if(fraction<1)animation=requestAnimationFrame(frame);
  }
  animation=requestAnimationFrame(frame);
}

const rad=Math.PI/180, cx=262, cy=123, separation=148, wx=cx+separation;
const r=separation/Math.sqrt(2), outer=111, start=225*rad;
function circle(x,y,radius,fill,stroke,w=1){
 ctx.beginPath();ctx.arc(x,y,radius,0,2*Math.PI);
 if(fill){ctx.fillStyle=fill;ctx.fill();}if(stroke){ctx.strokeStyle=stroke;ctx.lineWidth=w;ctx.stroke();}
}
function line(ax,ay,bx,by,color,width){
 ctx.beginPath();ctx.moveTo(ax,ay);ctx.lineTo(bx,by);ctx.strokeStyle=color;ctx.lineWidth=width;ctx.stroke();
}
let input=0;
function show(value){
 input=Math.min(360,Math.max(0,value));
 const theta=(input-45)*rad;
 const output=input<=90?45+Math.atan2(r*Math.sin(theta),separation-r*Math.cos(theta))/rad:90;
 const pin=[cx+r*Math.cos(theta),cy+r*Math.sin(theta)];
 ctx.fillStyle='#e7dbc4';ctx.fillRect(0,0,700,250);
 for(let y=10;y<250;y+=14)for(let x=5;x<700;x+=14){ctx.fillStyle='#baaf99';ctx.fillRect(x,y,1,1);}
 line(43,cy,655,cy,'#baaf9b',1);circle(cx,cy,r,null,'#a69a86',1.6);
 for(let i=0;i<48;i++){
   const a=i*Math.PI/24,inner=i%4?113:118;
   line(cx+Math.cos(a)*112,cy+Math.sin(a)*112,cx+Math.cos(a)*inner,cy+Math.sin(a)*inner,'#887e73',1);
 }
 ctx.save();ctx.translate(wx,cy);ctx.rotate(-output*rad);ctx.beginPath();
 // Each half-width is measured at the mouth of a radial slot.
 const gap=4.3,half=Math.asin(gap/outer);
 for(let n=0;n<4;n++){
   const a=start+n*Math.PI/2, ux=Math.cos(a),uy=Math.sin(a),vx=-uy,vy=ux;
   const lip=[outer*Math.cos(a-half),outer*Math.sin(a-half)];
   if(n===0)ctx.moveTo(lip[0],lip[1]);
   ctx.lineTo(33*ux-gap*vx,33*uy-gap*vy);
   ctx.lineTo(33*ux+gap*vx,33*uy+gap*vy);
   ctx.lineTo(outer*Math.cos(a+half),outer*Math.sin(a+half));
   const middle=a+Math.PI/4,end=a+Math.PI/2-half;
   ctx.quadraticCurveTo(51*Math.cos(middle),51*Math.sin(middle),outer*Math.cos(end),outer*Math.sin(end));
 }
 ctx.closePath();ctx.fillStyle='#56496b';ctx.fill();ctx.lineWidth=2;ctx.strokeStyle='#393146';ctx.stroke();
 for(let n=0;n<4;n++){
   const a=start+(n+.5)*Math.PI/2;
   circle(51*Math.cos(a),51*Math.sin(a),6,n===0?'#ffca7a':'#b6a2bd');
 }
 circle(0,0,18,'#342c42','#c9b8c2');circle(0,0,6,'#decdb5');ctx.restore();
 line(cx,cy,...pin,'#964c32',12);
 circle(cx,cy,18,'#ac6545','#643d30',2);circle(cx,cy,6,'#f3cc92');
 circle(...pin,7,'#ffd899','#683b27',2);
 ctx.fillStyle='#675b51';ctx.font='600 14px ui-monospace,monospace';ctx.fillText(tr('input'),28,36);
 ctx.textAlign='right';ctx.fillText(tr('output'),675,36);ctx.textAlign='left';
 const engaged=input<=90;
 by('angle').value=Math.round(input);by('status').textContent=tr(engaged?'engaged':'dwell');
 by('reading').textContent=tr('input')+' '+Math.round(input)+'°  /  '+tr('output')+' '+Math.round(output)+'°';
 board.dataset.input=input.toFixed(2);board.dataset.output=output.toFixed(2);board.dataset.engaged=String(engaged);
}
by('angle').oninput=e=>{cancelAnimationFrame(animation);show(+e.target.value);};
by('drive').onclick=()=>animate(input,45,470,show);
by('hold').onclick=()=>animate(input,200,650,show);
by('turn').onclick=()=>animate(0,360,2100,show);
show(0);
</script></body></html>
```

