本文へ移動
日本語
「三辺測位」は Pro に含まれます。解除するとプレビューが表示されます。

仕組み

A textbook figure of trilateration on an 18 × 7 m floor. Three anchors at known points each measure their distance to a tag, give or take a range error. Each reading puts the tag on a ring around its anchor: the measured range is drawn as a circle in the anchor's colour and the error as a pale band around it. The tag can only be where all three bands overlap, shaded in ink. The readout gives the worst case, the farthest point of that region from the tag, and the three ranges. Spread anchors cross their rings at wide angles and fix the tag within about the range error; anchors in a line cross at shallow angles, the region stretches, and a mirror image of the tag on the other side of the line fits the readings too. Drag the tag or an anchor; a press on the empty floor moves the tag there.

向いている場面

  • Teach how a position follows from distances, and why the placement of the anchors matters as much as the accuracy of each range.
  • Show the mirror ambiguity of anchors in a line, and how one anchor moved off the line resolves it.

向かない場面

  • For live positions from real sensors, use a map with an estimate and its confidence: this figure shows the ideal geometry, with every range off by at most the chosen error.

使い方

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

export function PositioningLesson() {
  const [points, setPoints] = useState({
    a: { x: 2, y: 1.5 },
    b: { x: 16, y: 1.5 },
    c: { x: 9, y: 6 },
    tag: { x: 11, y: 3.5 },
  })
  return (
    <AnchorRangeAtlas
      value={points}
      onChange={(next, { worst }) => setPoints(next)}
      defaultRangeError={0.25}
      labels={{ title: 'Locate a tag from three ranges' }}
    />
  )
}

プロパティ

プロパティ型既定値説明
value{ a, b, c, tag }—三つのアンカーとタグの位置を外部から指定します。それぞれ { x, y }(メートル)、床は 18 × 7 m です(0.1 刻みに丸めます)。
defaultValue{ a, b, c, tag }{ a: { x: 2, y: 1.5 }, b: { x: 16, y: 1.5 }, c: { x: 9, y: 6 }, tag: { x: 11, y: 3.5 } }内部状態での初期位置です。どちらの使い方でもリセットはここに戻ります。
onChange(points, reading) => void—新しい位置と { object('a'、'b'、'c'、'tag'、リセット時は null)、reason('drag'、'press'、'tap'、'key'、'cancel'、'reset')、ranges(三つの距離、m)、worst(ありうる位置のうちタグから最も遠い距離、m)、area(ありうる位置の面積、m²)} を受け取ります。
rangeErrornumber—測距誤差(m)を外部から指定します。各読み取り値はこの分だけ前後にずれえます。操作部は 0.25、0.5、1 を選べます。
defaultRangeErrornumber0.5内部状態での初期の測距誤差で、リセットでここに戻ります。
onRangeErrorChange(error, { reason }) => void—測距誤差が変わったときに呼ばれます。reason は 'press'、'key'、'reset' です。
labelsobject—組み込みの文言を置き換えます:title、caption、anchor('{name}')、tag、ring、overlap、floor、pointText('{name}'、'{point}')、rangeText('{name}'、'{point}'、'{range}')、movable、readout、rangeError、unit、reset。
localestring'en'数値の表示に使う言語タグです。
classNamestring—カードに追加するクラス名です。幅の指定などに使います(既定は 30rem、コンテナより広くなりません)。

アクセシビリティ

  • The three anchors and the tag are each one tab stop, a button with the role description 'movable point' and a name that reads its position (and, for an anchor, its range). Arrow keys move the focused point by 0.5 m, with Shift by 2 m, clamped to the floor; Escape during a drag puts it back.
  • The range error is a radio group with one tab stop; arrow keys change it. Reset is a button, marked unavailable while nothing has changed.
  • The readout is a polite live region: it reads the worst-case position error and the three ranges.
  • Dragging uses pointer capture. A handle sets touch-action: none, so the page does not scroll while a point is dragged; on the empty floor a tap places the tag and a swipe still scrolls the page. A cancelled gesture puts the point back where it started.
  • Colour is not the only key: the anchors carry their letters, the ranges in the readout are lettered, and the legend names the ring, the region and the tag.

モーション

After a key press, a tap or Reset the moved point glides for --ds-duration-fast while the rings and the region redraw at once; while a point is dragged it follows the pointer directly. With reduced motion every change lands at once.

プロジェクトに追加

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

AnchorRangeAtlas.jsxanchor-range-atlas.csstokens.cssREADME.md

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

グラフ