Go Down

Topic: Trying to map the outline of hypo/epicycloids (Read 2444 times) previous topic - next topic

subbywan

Hi all,

I've been working on this for a while now, using 2 HiTech HS-422 servos, with an Arduino Uno.

I have the basic math correct, and am able to generate proper paired coordiates with the following:


Code: [Select]
  while(i < 360)
  {
  pos_x=((R-r)*cos(z)+d*cos(((R-r)/r)*z)); // Calculate the x-position with angle z
  pos_y=((R-r)*sin(z)-d*sin(((R-r)/r)*z)); // Calculate the y-position with angle z
  x_coord = (pos_x * 3); // Allows for greater overall image size control
  y_coord = (pos_y * 3); // Allows for greater overall image size control
  servo_x.write(x_coord); // Write to servo X
  servo_y.write(y_coord); // Write to servo y
  Serial.print("("); Serial.print(x_coord); Serial.print("),("); Serial.print(y_coord);Serial.println(")"); // Print paired coordinates for testing on http://www.shodor.org/interactivate/activities/SimplePlot/
  z++;
  i++;
  delay(500);
  }



I've attached a file with the first 1000 pairs. Using the site above, you can see the difference when you're connecting the points, or just using them as a scatter plot.

My problem is this:

How do I get only the outline/perimeter of the equation?

Instead of the outline of a triangle/square/whatever the equation creates, it's basically colouring the whole object in.

I have one possible solution where I hook up the laser diode, and pulse it when at the coordinate in question, and eventually, all the dots will overlap and you'll get the image, but I'm hoping for a far more elegant solution.

Thanks!


claudegu

Hi,

One way would be :

1 get the datas as you have done
2 sort all the datas you have from (x mini, y mini) to (x maxi y maxi)
3 use this new array to light the


exemple:
1
(45.00),(0.00)
(9.97),(11.60)
(-22.29),(38.63)
(-15.30),(8.42)
(-21.79),(-37.54)
(-4.08),(-20.61)
(41.46),(-0.33)
(24.67),(4.85)
(-18.73),(34.00)


2
(-22.29),(38.63)
(-18.73),(34.00)
(-15.30),(8.42)

(9.97),(11.60)
(24.67),(4.85)

(45.00),(0.00)


(-21.79),(-37.54)
(-4.08),(-20.61)

(41.46),(-0.33)
Stone age was not finished due to a lack of stones

Go Up