function [xp,yp,zp] = rot(x,y,z,inc,omega); % [xp,yp,zp] = rot(x,y,z,inc,omega); % takes vectors x,y,z and transforms them % rotates through angle of nodes omega % tilts through inclination inc % evaluate trig functions once: cosomega = cos(omega); sinomega = sin(omega); cosinc = cos(inc); sininc = sin(inc); % transform: % tilt by inclination angle around x axis % since perihelion is defined in generating ellipse % with ellip.m, node is on x-axis. % recall that argument of perihelion is defined from node xt = x; yt = y*cosinc - z*sininc; zt = z*cosinc + y*sininc; % these are NOT new axes, but the vectors themselves are % rotated in ecliptic coordinates. Thus, the next % transformation is truly about the z-axis, as it should % be. It is NOT about a rotated z-axis. Think of % transforming components, not basis vectors. % rotate around z axis by omega xp = xt*cosomega - yt*sinomega; yp = yt*cosomega + xt*sinomega; zp = zt;