Posts: 1
Threads: 1
Joined: Jun 2017
06-23-2017, 03:13 PM
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!
Posts: 1
Threads: 0
Joined: Aug 2017
08-16-2017, 11:47 AM
(This post was last modified: 11-09-2021, 03:45 PM by MatthewSev.)
(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?
Posts: 690
Threads: 71
Joined: Jan 2015
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;
Posts: 1
Threads: 0
Joined: Sep 2017
Thanks Jake. I assume this'll work like a charm.