本文へ移動
日本語
「高調波の重ね合わせ」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

一周期分の y = a₁ sin x + a₂ sin 2x + a₃ sin 3x を示す教科書風の図です。各調波はそれぞれのチャート色の細線で描かれ凡例に名前が出ます。合成波は濃いインクの太線です。軸は ±2.5 に固定されているので、振幅の変化は必ず形の変化として見えます。読み取り線は π/12 ごとに止まり、位置は x 軸上のピルに表示され、グラフ下の行にその点の合成値が出ます。各調波のスライダーで振幅を −1〜+1(中央が 0)で調整します。カード幅が 440px 未満では凡例の代わりに、同じ色見本と名前を持つスライダー行が凡例を兼ねます。400px 未満では各スライダーが名前の下に移ります。

向いている場面

  • フーリエ級数や重ね合わせの授業で、最初の数項からのこぎり波や方形波を組み立て、各項の寄与を確かめてもらいます。
  • 読み取り線を色の点が重なる位置や逆向きになる位置に動かして、二つの波が強め合う・打ち消し合う理由を説明します。

向かない場面

  • 時間に沿って測ったデータには折れ線グラフを使ってください。この図は関数を描くもので、測定値ではありません。

使い方

import React, { useState } from 'react'
import { HarmonicSumSheet } from './HarmonicSumSheet.jsx'

const sawtooth = [1, -0.5, 0.33]

export function FourierLesson() {
  const [mix, setMix] = useState(sawtooth)
  return (
    <HarmonicSumSheet
      value={mix}
      defaultValue={sawtooth}
      onChange={(next) => setMix(next)}
      labels={{ title: 'Toward a sawtooth wave' }}
    />
  )
}

プロパティ

プロパティ型既定値説明
value[number, number, number]—基本波、第2・第3高調波の振幅を外部から指定します。各 −1〜+1(小数2桁に丸めます)。
defaultValue[number, number, number][1, -0.5, 0.33]内部状態の初期振幅です。どちらの使い方でもリセットはこの値に戻ります。
onChange(mix, details) => void—新しい振幅と { harmonic(1〜3、リセット時は null)、reason('press'、'drag'、'tap'、'key'、'cancel'、'reset')、position、sum } を受け取ります。
positionnumber—読み取り位置を π の倍数(0〜2)で外部から指定します。π/12 刻みに丸めます。
defaultPositionnumber0.75読み取り位置の初期値(π の倍数。0.75 は 3π/4)。
onPositionChange(position, { reason, sum }) => void—読み取り位置が動いたときに、π の倍数での位置とそこでの合成値を渡して呼ばれます。
stepnumber0.05ドラッグと矢印キーの振幅の刻みです。Shift と矢印、または Page Up と Page Down で5刻み動きます。
labelsobject—組み込みの文言を置き換えます:title、formula、names(三つ)、sum、readout('{x}' は位置)、position、positionText('{x}'、'{sum}')、amplitudes、amplitudeText('{value}')、reset。
localestring'en'小数の表示に使う言語タグです。
classNamestring—カードに追加するクラス名です。幅の指定などに使います(既定は 30rem、コンテナより広くなりません)。

アクセシビリティ

  • The plot is a slider for the playhead: Left and Right arrows move it by π/12, Shift with an arrow or Page Up and Page Down by π/4, Home and End go to 0 and 2π. Its value text reads the position and the sum there.
  • Each amplitude is a slider labelled with its harmonic's name: arrows move one step, Shift with an arrow or Page Up and Page Down five steps, Home and End go to −1 and +1. Its value text reads the amplitude.
  • The sum at the playhead is a polite live region. Reset is a button; it is marked unavailable while nothing has changed.
  • Dragging uses pointer capture. On touch, a press on a slider's track or on the plot changes nothing until the finger moves sideways or lifts, so vertical scrolling is not caught; a cancelled gesture restores the value it started from.
  • Colour is not the only key: the legend names each line, the sum is thicker, and the slider rows repeat the names with the same swatches.

モーション

キー操作、タップ、リセットの後は、曲線・点・読み取り線・つまみが --ds-duration-fast でなめらかに動きます。スライダーをドラッグしている間はポインターにそのまま追従します。視差効果を減らす設定では、すべての変化がすぐに反映されます。

プロジェクトに追加

Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。

HarmonicSumSheet.jsxharmonic-sum-sheet.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

グラフ
「三辺測位」は Pro に含まれます。解除するとプレビューが表示されます。