_About my lab

_About me

Problem Set 3

Algorithm to generate double curvature surfaces

discretized by scissors mechanism

I am still working in a grashopper - python algorithm to animate in 3D the scissors mechanisms that generate double curvature boundary surfaces. Firstly Im defining the geometry by reading a spine curve and apply translations (as we saw at class).

Secondly Im reading that geometry and animate it following the same step that Joon did at the recitation, but in the python enviroment.

Now that I can do that, I will take two curves and rotate one of them. In the animation I set some control points that varys with the movement. Those points sets the center of the orthogonal couple. The record of the animation before breaking rhino was a curve of 4000 pieces. Need to rewrite some way to make the code lighter in elements

img img img img The code Im developing is the following:

ANIMATION:

  """Provides a scripting component.
      Inputs:
          x: The x script variable
          y: The y script variable
      Output:
          a: The a output variable"""

  __author__ = "Alfonso"
  __version__ = "2020.10.03"

  import rhinoscriptsyntax as rs

  plane=rs.WorldXYPlane()

  updistances = []
  downdistances = []

  for lines in uplines:
      uppoints = []
      uppoints.append(rs.CurveStartPoint(lines))
      uppoints.append(rs.CurveEndPoint(lines))
      updistances.append(rs.Distance(uppoints[0], uppoints[1]))

  for lines in downlines:
      downpoints = []
      downpoints.append(rs.CurveStartPoint(lines))
      downpoints.append(rs.CurveEndPoint(lines))
      downdistances.append(rs.Distance(downpoints[0], downpoints[1]))

  testing_pair = [downlines[0], uplines[0]
  ]
  testing_starting_point = rs.CurveStartPoint(downlines[0])


  #primero down eh
  def animate(starting_point, pair, offset):
      p1 = starting_point
      p2 = rs.CopyObject(p1)
      p2 = rs.MoveObject(p2, (0,-offset,0))

      c1 = rs.AddCircle(plane, (rs.Distance(rs.CurveStartPoint(pair[0]),rs.CurveEndPoint(pair[0])))/2)
      c2 = rs.AddCircle(plane, (rs.Distance(rs.CurveStartPoint(pair[1]),rs.CurveEndPoint(pair[1])))/2)

      c1 = rs.MoveObject(c1,p1)
      c2 = rs.MoveObject(c2,p2)

      intersection =rs.CurveCurveIntersection(c1,c2)

      if intersection[0][1][0] > intersection[1][1][0]:
          int = intersection[0][1]
      else:
          int = intersection[1][1]


      fl1 = rs.AddLine(p1, int)
      fl2 = rs.AddLine(p2, int)

      fL1 = rs.ScaleObject(fl1, p1, (2,2,2))
      fL2 = rs.ScaleObject(fl2, p2, (2,2,2))




      return  fL2, fL1

  #test =animate(testing_starting_point, testing_pair, offset)[0]

  pairs = []

  for element in range(len(uplines)):
      pair = []
      pair.append(downlines[element])
      pair.append(uplines[element])
      pairs.append(pair)






  start = rs.CurveStartPoint(downlines[0])
  geometry = []
  midpoints = [rs.AddPoint(start[0], start[1]-offset/2,start[2])]
  for pair in pairs:
      geom = animate(start, pair, offset)
      start = rs.CurveEndPoint(geom[0])
      geometry.append(geom)
      midpoints.append(rs.AddPoint([start[0], start[1]-offset/2,start[2]]))



  flat_list = []

  for sublist in geometry:
      for item in sublist:
          flat_list.append(item)

  test = flat_list

  midp =midpoints

  #test = animate(start, pairs[0], offset)

Drawing Skeleton

   """Provides a scripting component.
       Inputs:
           x: The x script variable
           y: The y script variable
       Output:
           a: The a output variable"""

   __author__ = "Alfonso"
   __version__ = "2020.10.03"

   import rhinoscriptsyntax as rs
   plane = rs.WorldXYPlane()

   #me da que esta primera face del codigo va a ser tan solo formar y
   #congelar la geometria? Luego la congelamos y pasamos a moverla . Esto cambiara si cambia la....curva?
   # un script vs dos?

   Curve_copy1 = rs.CopyObject(Curve)
   Curve_copy2 = rs.CopyObject(Curve)



   crv_upper = rs.MoveObject(Curve_copy1, [0,offset_value,0])
   crv_lower = rs.MoveObject(Curve_copy2, [0,-offset_value,0])


   b = rs.AddLine((0,0,0),(0,100,0))
   a = rs.MoveObject(b,[0,10,0])
   upper_points = []
   lower_points = []

   upper_points = rs.DivideCurve(crv_upper, segments, create_points = True)
   lower_points = rs.DivideCurve(crv_lower, segments, create_points = True)








   #Draw the scissors accordingly with the input geom.
   up_segments = []
   down_segments = []

   for pt in range(segments):
       local_up = rs.AddLine(lower_points[pt], upper_points[pt+1])
       up_segments.append(local_up)
       local_down = rs.AddLine(upper_points[pt], lower_points[pt+1])
       down_segments.append(local_down)



   uplines=up_segments
   downlines=down_segments

 

So, WIP. It is not robust when I change the planes. There is something weird in the rhino - grashopper - python global axis communication....

back to menu