Back

Version 6

10/8/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect, useRef } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import Chart from "https://esm.sh/chart.js/auto";

const R = 120; // Set R as a constant

function gcd(a: number, b: number): number {
return b === 0 ? a : gcd(b, a % b);
}

function lcm(a: number, b: number): number {
return (a * b) / gcd(a, b);
}

function App() {
const chartRef = useRef(null);
const chartInstanceRef = useRef(null);
const [rho, setRho] = useState(60);
const [tMax, setTMax] = useState(0);

useEffect(() => {
if (chartInstanceRef.current) {
chartInstanceRef.current.destroy();
}
if (chartRef.current) {
const ctx = chartRef.current.getContext('2d');
const omega = 2 * Math.PI;
const zeta = R / rho;
const tMax = lcm(R, rho) / R;
const numPoints = 1000;
const tStep = tMax / numPoints;

// Generate points for the curve
efoley-spiroplot.web.val.run
Updated: October 9, 2024