Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate distance between control points.
#1
Big Grin 
First post and fairly new to curvy.

Any suggestions on how I could go about calculating the distance between two control points on the same spline? My plan is to dynamically create a control point at the mid point between two control points.

Thanks!
Reply
#2
(06-23-2017, 03:13 PM)_niceo Wrote: First post and fairly new to curvy.

Any suggestions on how I could go about calculating the distance between two control points on the same spline? My plan is to dynamically create a control point at the mid point between two control points.

Thanks!

Hi Nico, did you figure out how to do it?
Reply
#3
Each CP have a Length property as well as a Distance one. The latter tells the Distance from the start of spline.
So if you want to split a segment in half do something like:

Code:
var pos=spline.InterpolateByDistance(cp.Distance+cp.Length/2);
var newCP=spline.InsertAfter(cp);
newCP.position=pos;
Reply
#4
Thanks Jake. I assume this'll work like a charm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Video How do I merge splines only if some control points are at the sam position? arcade.autumn 5 14 02-13-2023, 09:35 AM
Last Post: _Aka_
  Control handles gone for control points! :( danne_lindwall 3 5 02-10-2023, 08:49 AM
Last Post: _Aka_
  Shapes points orientation itsGama 3 5 01-18-2023, 02:51 PM
Last Post: _Aka_
  Closed splines and duplicate points jh092 3 6 07-24-2022, 01:54 PM
Last Post: _Aka_

Forum Jump: