function r(a, b, w, th) {
function R(t) {
let sint = sin(t);
let cost = cos(t);
let sinth = sin(th);
let costh = cos(th);
let coswt = cos(w * t);
let norm = Math.sqrt(a ** 2 * sint ** 2 + b ** 2 * cost ** 2);
let x = (coswt * (a * sinth * sint - b * costh * cost)) / norm + a * cost;
let y = (-coswt * (a * costh * sint + b * sinth * cost)) / norm + b * sint;
let z = sin(w * t);
return [x, y, z];
}
return R;
}