Home > database >  How to convert Cartesian coordinates epitrochoid graph into polar coordinates in pascalABC?
How to convert Cartesian coordinates epitrochoid graph into polar coordinates in pascalABC?

Time:07-07

For my student project I need to create pascalABC.NET program that makes Epitrochoid graph in Cartesian and Polar coordinate systems. I made some simple code for Cartesian system and it seems to work pretty well, how can i convert it to polar system now? Is there any math equations for epitrochoid in polar system that i can use for this program? Hope someone can help me :)

Code i made for Cartesian system:

uses graphABC;
var c,x,y:integer;
r1,r2,m,h,t,ms:real;
begin
setwindowsize(500,500);
centerwindow;
c:=250;
r1:=1;
r2:=0.2;
m:=r2/r1;//m=0.2
h:=0.3;
ms:=(c-50)/(r1 2*r2);
setpenwidth(2);
setpencolor(clGreen);
circle(c,c,round(r1*ms));
setpencolor(clRed);
t:=0;
while t<=360 do
 begin
  x:=c round((r1*(m 1)*cos(m*t)-h*cos((m 1)*t))*ms);
  y:=c-round((r1*(m 1)*sin(m*t)-h*sin((m 1)*t))*ms);
  if t=0 then moveto(x,y) else lineto(x,y);
  t:=t 0.1;
 end;
end.

Thats how graph looks in Cartesian system

CodePudding user response:

You cannot build explicit function ro(theta) for epitrochoid.

It is possible to make ro(t) and theta(t) for t parameter:

ro = sqrt(x^2   y^2)
theta = arctan2(y, x)

where x, y are expressions like your r1*(m 1)*cos(m*t)-h*cos((m 1)*t))*ms

Example of formula derivation for epicycloid
and result for epitrochoid

Seems a bit unnatural, in my mind...

Problems - it is hard to get equal-spaced points by theta, also note that one theta value might correspond to two ro values (loops at your picture).

  • Related