Whilst working on a function to approximate a spline, I believe I have found a bug pertaining to the calculation of the second derivative at points along the spline (as calculated by the vlax-curve-getsecondderiv function) after the spline has been scaled.
Steps to reproduce the problem:
1. Construct a spline in the drawing with spline method set to 'Fit'.
2. Run the following program on the spline created:
(defun c:test ( / der di1 di2 ent inc )
(if (setq ent (car (entsel)))
(progn
(setq di1 (vlax-curve-getdistatparam ent (vlax-curve-getstartparam ent))
di2 (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))
inc (/ di2 20.0)
)
(while (< di1 di2)
(setq der (cons (distance '(0.0 0.0 0.0) (vlax-curve-getsecondderiv ent (vlax-curve-getparamatdist ent di1))) der)
di1 (+ di1 inc)
)
)
(print di2)
(princ (/ (apply '+ der) (length der)))
)
)
(princ)
)
(vl-load-com) (princ)
The above program will print the length of the spline, along with the average magnitude of the second derivative at 20 points along the spline.
3. Using the SCALE command, scale the spline by any scale factor, using any base point.
4. Run the above program again on the scaled spline.
If the spline has been scaled up, the average second derivative would be expected to decrease; if scaled down, this average would be expected to increase (since the spline will have tighter curves).
5. Use the COPY command to copy the scaled spline.
6. Run the above program on the copied spline.
One would expect the results of running the program on the copied spline to be identical to those reported by the program before the spline was copied (since the spline geometry has not changed).
Here are my results:
Original Spline:
Length Ave. 2nd Deriv
32.6029 0.108747
Spline Scaled by 2:
Length Ave. 2nd Deriv
65.2059 0.217493 <--- this should be half, not double :-(
Copy of Scaled Spline:
Length Ave. 2nd Deriv
65.2059 0.051784 <--- value is now correct for copied spline
Observe that scaling the spline causes the average magnitude of the second derivative to increase by the scale factor, rather than decrease by a reciprocal of the scale factor.
Hence, in my example above,
Original Average 2nd Deriv is 0.108747
After scaling the spline by 2, this average is also doubled to 0.217493 (rather than halved)
After copying, the correct (halved) average is returned: 0.051784
Can anyone else replicate these results?