Ir al contenido
Español
Trilateración viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • 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.

Busca otra opción cuando

  • 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.

Uso

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' }}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
value{ a, b, c, tag }—Posiciones controladas de las tres anclas y la etiqueta, cada una { x, y } en metros sobre una planta de 18 × 7 m (redondeadas a 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 } }Posiciones iniciales sin control externo y el destino de Restablecer en ambos modos.
onChange(points, reading) => void—Recibe las nuevas posiciones y { object ('a', 'b', 'c', 'tag' o null al restablecer), reason ('drag', 'press', 'tap', 'key', 'cancel' o 'reset'), ranges (tres distancias en metros), worst (la posición posible más alejada de la etiqueta, en metros), area (de las posiciones posibles, en m²) }.
rangeErrornumber—Error de distancia controlado en metros: cada lectura puede desviarse esto hacia cualquier lado. El control ofrece 0,25, 0,5 y 1.
defaultRangeErrornumber0.5Error de distancia inicial sin control externo y el que recupera Restablecer.
onRangeErrorChange(error, { reason }) => void—Se llama al cambiar el error de distancia, con reason 'press', 'key' o 'reset'.
labelsobject—Sustituye cualquier texto integrado: title, caption, anchor ('{name}'), tag, ring, overlap, floor, pointText ('{name}', '{point}'), rangeText ('{name}', '{point}', '{range}'), movable, readout, rangeError, unit y reset.
localestring'en'Etiqueta de idioma para las cifras.
classNamestring—Clase extra para la tarjeta, por ejemplo para fijar su ancho (30rem por defecto, nunca más que su contenedor).

Accesibilidad

  • 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.

Movimiento

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.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

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

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Gráficos