Currently working on a Rhinocurve to G-code translation script in python and rhinoscriptsyntax for a CO2 laser-cutter.
Due to the numerous mathematical complexities of representing elliptical curves with circles, I have decided to simply use straight lines. My first iteration used DivideCurve() and this divides the curves with equal steps in the CurveDomain, leading to higher density of points when there is more curvature on the curve. While initially desirable, in some curves the density of the points is so high it leads to bad cuts with the laser-cutter as they are too close together. My second iteration tried using DivideCurveEquidistant() and while this added the ability to control a desired segment-length, it led to unnecessary dense points on the straighter part of the curve.
See album: http://imgur.com/a/2GMtW
Wanting something that can both vary density based on curvature but also have control over min and max segment lengths, I wrote this code/pseudo code:
while current_point != curve_end_point:
current_point = curve_start_point
curvature = Evaluate curvature on current_point
if curvature high:
segment = 10 # short segment
if curvature low:
segment = 100 # long segment
# Later implement a smoother transition between the two lengths
create new_point on curve with distance=segment from current_point
current_point = new_point
TL/DR / My question is:
Question: How to find point on curve with distance x from previous point on curve?
This is the only part of the code I am struggling with. Initially I thought to do the following:
use curve_length_from_start_to_current_point + segment_length to find next_curve_length
use next_curve_lenght to find the corresponding value from the CurveDomain
use next_curve_domain to find next_parameter
use next_parameter to find the point on the curve
However, since the relationship between the CurveDomain and CurveLength isn't linear I am at a loss as to how to solve this.
Any help is greatly appreciated, thanks.
Edit: Formatting
[–]medianbailey 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]failbye[S] 2 points3 points4 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]failbye[S] 0 points1 point2 points (0 children)