Grasshopper

algorithmic modeling for Rhino

What is the definition of the t length parameter used to define a position laong the length of a curve. I had thought it was simply a normalized value from 0 to 1 representing a percentage distance along a curve but from the results of my code that is not true and one must also frist determine the value of t i.e.:

 

To get a point at the mid point of a curve:

 

Dim rcTParameter As Double

ghobject.Value.LengthParameter(ghobject.Value.GetLength * 0.5, rcTParameter)

rmaPoint.X = ghobject.Value.PointAt(rcTParameter).X

 

I had hoped that t was betwwen 0 and 1  and I could have simply written:

 

rmaPoint.X = ghobject.Value.PointAt(0.5).X

 

thanks

 

 

 

Views: 747

Replies to This Discussion

Hi Duck,

Curve.PointAt() uses curve parameter space which may not be (indeed most often is not) linear. Therefore the halfway point on the curve domain is only rarely also the halfway point on the curve.

You could use the Curve.NormalizedLengthParameter, which works in the 0.0~1.0 range:

Dim t As Double
If (Not ghobject.Value.NormalizedLengthParameter(0.5, t)) Then Return
rmaPoint.X = ghobject.Value.PointAt(t).X


It would be easier in some cases if NormalizedLengthParameter returned the double instead of a boolean, but at least this way it is obvious that the function can fail and that you should always check the return value for validity.

I do see your point though, I'll have a pow-wow with Steve to see if we're happy adding a special PointAt() method that takes normalized length parameters instead of curve parameters.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David. I guess I need to read up on "curve parameter space"!!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service