Grasshopper

algorithmic modeling for Rhino

I found this Rhinoscript for determining the torsion of a curve at a given point . Can anyone convert it to a GH script for me?

 

 

'''
''' Description
''' Evaluate the torsion of a curve.
''' Parameters
''' crv - a string that identifies the curve to evaluate
''' t - a parameter of the curve within its domain
''' Returns
''' The torsion if successful.
''' Null if the torsion is undefined at the parameter.
'''
Function EvaluateTorsion(crv, t)

  ' Local variables
  Dim data, d1xd2, numer, denom

  ' Default return value
  EvaluateTorsion = Null

  ' Calculate the torsion
  data = Rhino.CurveEvaluate(crv, t, 3)
  If IsArray(data) And UBound(data) = 3 Then
    d1xd2 = Rhino.VectorCrossProduct(data(1), data(2))
    numer = Rhino.VectorDotProduct(d1xd2, data(3))
    denom = Rhino.VectorDotProduct(d1xd2, d1xd2)
    If denom > 0 Then
      EvaluateTorsion = numer / denom
    End If
  End If

End Function

Views: 1437

Replies to This Discussion

Translated to the best of my abilities. I don't know if the result is actually correct though.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

As always, David, your willingness to assist is above and beyond. =)

 

Are you still going to add a torsion component into GH in the future?

I can certainly add this as a component. Do you think many people would use it?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I added both a Torsion and a Derivatives component. Dropdown only as these are pretty darn geeky.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Sweet! Really taking on Mathematica now man! ;D

 

I definitely can't attest to anyone else, but I WILL be using these!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service