Skip to content

Vectors & Vector Fields

<Vector> draws a single arrow between two points in math coordinates, while <VectorField> visualizes a two-dimensional field of arrows defined by a function.

-4-3-2-11234-3-2-1123v
0.00s / 2.97s · F0
PropTypeDefaultDescription
from[number, number][0, 0]Start point in math coordinates
to[number, number]End point in math coordinates
origin[number, number][200, 200]Pixel position of the coordinate origin
scalenumber40Pixels per unit
colorstring'currentColor'Arrow color
strokeWidthnumber2Stroke width
labelstringundefinedText label rendered near the arrow
labelOffset[number, number][0, -10]Pixel offset for the label
PropTypeDefaultDescription
fn(x: number, y: number) => [number, number]Function mapping each point to a direction
domain[number, number][-5, 5]x-range of the field
range[number, number][-5, 5]y-range of the field
origin[number, number][200, 200]Pixel position of the coordinate origin
scalenumber40Pixels per unit
colorstring'#4f46e5'Arrow color
arrowScalenumber1Multiplier for arrow length
normalizebooleanfalseNormalize all arrows to the same length
spacingnumber1Grid spacing between arrows in math units
fadeInbooleanfalseAnimate arrows in on mount
import { Player, FadeIn, Axes, Vector } from '@elucim/core';
<Player width={500} height={350} fps={30} durationInFrames={60}>
<Axes origin={[250, 200]} xRange={[-4, 4]} yRange={[-3, 3]} scale={50}
color="currentColor" labelColor="currentColor" />
<FadeIn duration={20}>
<Vector from={[0, 0]} to={[3, 2]} origin={[250, 200]} scale={50}
color="#6c5ce7" strokeWidth={2.5} label="v" />
</FadeIn>
</Player>