An interactive web-based tool for visualizing 2D and 3D vector fields with beautiful color plots and rotatable 3D views.
- ✅ Expression Input: Enter mathematical expressions like
i*x + j*yori*sin(x) + j*cos(y) - ✅ Beautiful Color Plots: Color by magnitude, direction, or solid colors
- ✅ Rotatable 3D: Full 3D visualization with mouse controls (drag to rotate, scroll to zoom)
- Arrows: Classic arrow representation showing direction and magnitude
- Field Lines: Streamlined view with lines along the field
- Particles: Point-based visualization
- Dimension Switch: Toggle between 2D (XY plane) and 3D (XYZ space)
- Adjustable Density: Control the number of vectors displayed (5-30 per axis)
- Arrow Scale: Adjust vector size for better visibility
- Domain Control: Set custom X, Y, Z ranges
- Color Modes:
- Magnitude: Blue (low) to Red (high)
- Direction: Hue-based directional coloring
- Solid: Single color display
- Animation: Time-varying fields (use
tvariable in expressions) - Preset Examples: Quick-load common vector fields
- Circular flow
- Radial expansion
- Wave patterns
- Vortex
- Saddle point
- 3D circular flow
- Export: Save visualizations as PNG images
- Real-time Stats: View point count and maximum magnitude
- Open the App: Simply open
index.htmlin a modern web browser - Enter Expression: Type a vector field expression in the input box
- Click Update: Click "Update Visualization" or press Enter
Use standard mathematical notation:
Unit Vectors:
i= x-directionj= y-directionk= z-direction
Variables:
x,y,z= spatial coordinatest= time (for animations)
Functions:
sin(),cos(),tan()exp(),log(),sqrt()abs(),ceil(),floor()
Operators:
+,-,*,/,^(power)
2D Fields:
i*(-y) + j*x // Circular flow
i*x + j*y // Radial expansion
i*sin(y) + j*sin(x) // Wave pattern
i*(-y/(x^2+y^2)) + j*(x/(x^2+y^2)) // Vortex
i*cos(x)*sin(y) + j*sin(x)*cos(y) // Saddle point
3D Fields:
i*(-y) + j*x + k*z // 3D helical flow
i*x + j*y + k*z // Radial expansion from origin
i*sin(z) + j*cos(z) + k*0 // Z-dependent rotation
Time-Varying (Animated):
i*cos(t)*x + j*sin(t)*y // Rotating field
i*sin(x-t) + j*cos(y-t) // Traveling wave
Mouse (3D Mode):
- Click + Drag: Rotate view
- Scroll: Zoom in/out
Keyboard:
- Enter: Update visualization when in expression field
Buttons:
- Update Visualization: Re-render with current settings
- Reset View: Return camera to default position
- Export Image: Download current view as PNG
- Three.js (r128): 3D rendering and visualization
- Math.js (11.11.0): Expression parsing and evaluation
- Vanilla JavaScript: No framework dependencies
- Modern CSS: Gradient backgrounds and smooth animations
The application consists of four main components:
- index.html: UI structure and controls
- style.css: Modern, responsive styling
- vectorField.js: Vector field parsing and computation
- renderer.js: Three.js-based 3D/2D rendering
- app.js: Main application logic and event handling
Tested and working on:
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Requires WebGL support.
-
Avoid Singularities: Be careful with expressions like
1/xor1/(x^2+y^2)that have singularities. The app filters vectors with magnitude > 1000. -
Adjust Density: Lower density (5-10) for complex 3D fields, higher density (20-30) for smooth 2D visualizations.
-
Scale Matters: If vectors are too small/large, adjust the "Arrow Scale" slider.
-
Animation Performance: Use lower density when animating for smoother framerates.
-
Domain Range: Adjust X, Y, Z ranges to focus on interesting regions of your field.
-
Color by Direction: Use "Direction" color mode to see field rotation patterns more clearly.
Potential features for future versions:
- Streamline integration (true field lines following flow)
- Divergence and curl visualization
- Vector field composition (overlay multiple fields)
- Coordinate system transforms (polar, cylindrical, spherical)
- Field line tracing with particle animation
- More export formats (SVG, WebM video)
- Save/load configurations
- URL sharing with encoded parameters
Free to use and modify for educational and personal projects.
Created with GitHub Copilot - February 2026
Enjoy exploring vector fields! 🎨📐