| name | triangle |
| description | Create triangle geometry figures with vertices, angles, special lines, and labels. Use when rendering triangles in mini-lessons or geometry questions. |
Triangle Figure Skill
This skill guides you through creating triangle visualizations using the TriangleFigure component.
When to Use This Skill
Invoke this skill when:
- Creating geometry mini-lessons involving triangles
- Rendering triangles in practice questions
- Visualizing triangle properties (angles, special lines)
- Building interactive triangle explorations
- Demonstrating teorema de Pitágoras, área de triángulos, etc.
Quick Start
Forma más simple: Usando ángulos
import { TriangleFigure } from '@/components/figures/TriangleFigure';
<TriangleFigure fromAngles={[60, 60, 60]} />
<TriangleFigure fromAngles={[30, 60, 90]} showRightAngleMarker />
<TriangleFigure fromAngles={[45, 45, 90]} showGrid />
Con tamaño personalizado
<TriangleFigure
fromAngles={{ angles: [30, 60, 90], size: 200 }}
showGrid
/>
Usando longitudes de lados
<TriangleFigure fromSides={[3, 4, 5]} showRightAngleMarker />
<TriangleFigure fromSides={[5, 5, 5]} />
<TriangleFigure
fromSides={{ sides: [5, 12, 13], size: 200 }}
showRightAngleMarker
/>
Triángulo rectángulo con labels
<TriangleFigure
fromAngles={[30, 60, 90]}
showRightAngleMarker
sides={[
{ label: 'c' },
{ label: 'a' },
{ label: 'b' },
]}
/>
Con arcos de ángulos
<TriangleFigure
fromAngles={[60, 60, 60]}
angles={[
{ showArc: true, showDegrees: true },
{ showArc: true, showDegrees: true },
{ showArc: true, showDegrees: true },
]}
/>
Con altura (línea especial)
<TriangleFigure
fromAngles={[50, 60, 70]}
specialLines={[
{
type: 'altura',
fromVertex: 0,
strokeStyle: 'dashed',
showLabel: true,
showRightAngleMarker: true,
},
]}
/>
Usando vértices (control total)
Cuando necesitas control preciso sobre las coordenadas:
<TriangleFigure
vertices={[
{ x: 200, y: 50, label: 'A' },
{ x: 100, y: 220, label: 'B' },
{ x: 300, y: 220, label: 'C' },
]}
showGrid
/>
Props Reference
Construcción del triángulo (usar UNO de estos)
| Prop | Type | Description |
|---|
fromAngles | [number, number, number] o { angles, size?, rotation? } | Recomendado. Construir desde ángulos |
fromSides | [number, number, number] o { sides, size?, rotation? } | Construir desde longitudes de lados |
vertices | [LabeledPoint, LabeledPoint, LabeledPoint] | Control total de coordenadas |
fromAngles
fromAngles={[60, 60, 60]}
fromAngles={{
angles: [30, 60, 90],
size: 200,
rotation: 0,
}}
fromSides
fromSides={[3, 4, 5]}
fromSides={{
sides: [5, 12, 13],
size: 200,
rotation: 0,
}}
Nota: Los lados deben cumplir la desigualdad triangular: la suma de dos lados siempre debe ser mayor que el tercero.
LabeledPoint
interface LabeledPoint {
x: number;
y: number;
label?: string;
labelOffset?: { x: number; y: number };
}
Side Configuration
interface SideConfig {
label?: string;
measurement?: string;
color?: string;
strokeStyle?: 'solid' | 'dashed' | 'dotted';
showMeasurement?: boolean;
}
Angle Configuration
interface AngleConfig {
label?: string;
showArc?: boolean;
arcRadius?: number;
color?: string;
isExterior?: boolean;
showDegrees?: boolean;
}
Special Lines
interface SpecialLineConfig {
type: 'altura' | 'mediana' | 'bisectriz' | 'mediatriz';
fromVertex: 0 | 1 | 2;
color?: string;
strokeStyle?: 'solid' | 'dashed' | 'dotted';
showLabel?: boolean;
showRightAngleMarker?: boolean;
}
Visual Options
| Prop | Type | Default | Description |
|---|
fill | string | 'rgba(59,130,246,0.15)' | Color de relleno |
fillOpacity | number | - | Opacidad del relleno |
stroke | string | 'rgb(59,130,246)' | Color del borde |
strokeWidth | number | 2 | Ancho del borde |
showGrid | boolean | false | Mostrar cuadrícula |
gridSize | number | 20 | Tamaño de celda de la cuadrícula |
showVertices | boolean | true | Mostrar puntos en los vértices |
vertexRadius | number | 4 | Radio de los puntos de vértice |
showRightAngleMarker | boolean | false | Mostrar marcador de ángulo recto |
rightAngleVertex | 0 | 1 | 2 | auto | Vértice con ángulo recto |
rightAngleSize | number | 12 | Tamaño del marcador |
SVG Options
| Prop | Type | Default | Description |
|---|
width | number | auto | Ancho del SVG |
height | number | auto | Alto del SVG |
viewBox | string | auto | ViewBox personalizado |
padding | number | 40 | Padding alrededor del triángulo |
className | string | - | Clases CSS adicionales |
Common Patterns
Teorema de Pitágoras
<TriangleFigure
vertices={[
{ x: 50, y: 50, label: 'A' },
{ x: 50, y: 200, label: 'B' },
{ x: 200, y: 200, label: 'C' },
]}
sides={[
{ label: 'c', measurement: '5 cm' },
{ label: 'a', measurement: '3 cm' },
{ label: 'b', measurement: '4 cm' },
]}
showRightAngleMarker
rightAngleVertex={1}
showGrid
/>
Suma de Ángulos Interiores
<TriangleFigure
vertices={[
{ x: 200, y: 50, label: 'A' },
{ x: 100, y: 220, label: 'B' },
{ x: 300, y: 220, label: 'C' },
]}
angles={[
{ showArc: true, label: 'α' },
{ showArc: true, label: 'β' },
{ showArc: true, label: 'γ' },
]}
/>
Altura y Área
<TriangleFigure
vertices={[
{ x: 200, y: 40, label: 'A' },
{ x: 80, y: 220, label: 'B' },
{ x: 320, y: 220, label: 'C' },
]}
sides={[
{},
{},
{ label: 'base' },
]}
specialLines={[
{
type: 'altura',
fromVertex: 0,
strokeStyle: 'dashed',
showLabel: true,
showRightAngleMarker: true,
},
]}
/>
Medianas y Centroide
<TriangleFigure
vertices={[
{ x: 200, y: 50, label: 'A' },
{ x: 100, y: 220, label: 'B' },
{ x: 300, y: 220, label: 'C' },
]}
specialLines={[
{ type: 'mediana', fromVertex: 0, strokeStyle: 'dashed' },
{ type: 'mediana', fromVertex: 1, strokeStyle: 'dashed' },
{ type: 'mediana', fromVertex: 2, strokeStyle: 'dashed' },
]}
/>
Color Palette
| Elemento | Light Mode | Dark Mode |
|---|
| Triangle fill | fill-blue-200 | fill-blue-800/50 |
| Triangle stroke | stroke-blue-600 | stroke-blue-400 |
| Angle arc | stroke-amber-500 | stroke-amber-400 |
| Special lines | stroke-purple-500 | stroke-purple-400 |
| Right angle marker | stroke-red-500 | stroke-red-400 |
| Grid | stroke-gray-200 | stroke-gray-700 |
Debug Page
Para experimentar interactivamente con todas las opciones:
URL: /admin/figure-debug
La página de debug permite:
- Modo Vértices: Ajustar posición de vértices con sliders
- Modo Ángulos: Construir triángulo especificando los 3 ángulos interiores
- Seleccionar presets (equilátero, rectángulo, isósceles, escaleno, 30-60-90, 45-45-90)
- Activar/desactivar opciones visuales
- Agregar líneas especiales (altura, mediana, bisectriz)
- Copiar el código generado
Integration with Mini-Lessons
In Step Components
import { TriangleFigure } from '@/components/figures/TriangleFigure';
export default function Step2Explore({ isActive }: LessonStepProps) {
const [showAltura, setShowAltura] = useState(false);
return (
<div className="flex flex-col items-center">
<TriangleFigure
vertices={[...]}
specialLines={showAltura ? [{ type: 'altura', fromVertex: 0 }] : []}
/>
<button onClick={() => setShowAltura(!showAltura)}>
{showAltura ? 'Ocultar' : 'Mostrar'} altura
</button>
</div>
);
}
With Animation
import { motion } from 'framer-motion';
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.5 }}
>
<TriangleFigure vertices={[...]} />
</motion.div>
Utility Functions
Las funciones matemáticas están disponibles en @/lib/geometry/triangleUtils:
import {
distance,
midpoint,
centroid,
angleAtVertex,
altitudeFootPoint,
findRightAngleVertex,
buildTriangleFromAngles,
validateTriangleAngles,
buildTriangleFromSides,
validateTriangleSides,
} from '@/lib/geometry/triangleUtils';
Build Triangle from Angles
Puedes construir un triángulo especificando los 3 ángulos interiores:
import { buildTriangleFromAngles } from '@/lib/geometry/triangleUtils';
const vertices = buildTriangleFromAngles(
[30, 60, 90],
150,
200,
150,
0
);
Build Triangle from Sides
Puedes construir un triángulo especificando las 3 longitudes de lados:
import { buildTriangleFromSides } from '@/lib/geometry/triangleUtils';
const vertices = buildTriangleFromSides(
[3, 4, 5],
150,
200,
150,
0
);
Importante: Los lados deben cumplir la desigualdad triangular (a + b > c para todos los lados).