Author Topic: (vlax-curve-getclosestpointtoprojection-a)  (Read 2866 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3313
  • Marko Ribar, architect
(vlax-curve-getclosestpointtoprojection-a)
« on: December 12, 2013, 07:30:40 AM »
This function in title is my version of extension of orig. (vlax-curve-getclosestpointtoprojection) and can be found here :
http://www.cadtutor.net/forum/showthread.php?83402-Digital-design...which-software-can-generate-this-questiion/page3&p=#23

As you can see it uses trim command with "fence" option to perform trimming of copy of argument curve in order to achieve obtaining next possible point on curve that satisfies the cause that next point on curve with different parameter exist and is also closest point to projection... So my question is : command trim uses perpendicular points to tangent on curve in trimming point... As you can see when curves are 2d and in WCS it's all OK - trimming performs successful, but I was thinking can trim command be used to do job in 3d with basically the same action, but with points transformed from WCS to DCS... When tested code posted below at same thread on www.cadtutor.net - example is curve that have different z coordinates of start/end vertices and when used vector (normal of plane) (0 0 1), although there are more than one point solution, trimming in 3d fails at the beggining of (vlax-curve-getclosestpointtoprojection-a)... So althgough this code isn't applicable on all curve situations (CIRCLE, full ELLIPSE, XLINE, RAY, curve with both start/end point that is also one of return points by function), can this code be modified to work in 3d like orig. function does with that exception that it actually finds list of points instead of single solution point with smallest parameter of curve - first occurence?...

Thanks for any reply...
M.R.
« Last Edit: December 13, 2013, 05:46:26 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3313
  • Marko Ribar, architect
Re: (vlax-curve-getclosestpointtoprojection-a)
« Reply #1 on: December 12, 2013, 10:38:23 AM »
Just changed code a little on cadtutor... It was really small issue - something ab "_.erase" command inside function... Still the same question, any thoughts? Is there maybe some more elegant and efficient way to do the same job, but like orig. (vlax-curve-getclosestpointtoprojection) - not XLINE - intersectwith method... Like I said I need 3d solution with point list as result...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3313
  • Marko Ribar, architect
Re: (vlax-curve-getclosestpointtoprojection-a)
« Reply #2 on: December 12, 2013, 12:37:09 PM »
Again me... Just when I thought I solved it, it failed again... Now used VIEWDIR sysvar in conjunction with first derivative on point to obtain normal on tangent in point that is used in "fence" option while command "_.trim"... I just don't know; should I use (trans (mapcar '+ px nf) 0 2) and (trans (mapcar '- px nf) 0 2) for "fence" option? Look into updated code (px is point and nf normal on tangent and viewdir)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3313
  • Marko Ribar, architect
Re: (vlax-curve-getclosestpointtoprojection-a)
« Reply #3 on: December 12, 2013, 02:58:53 PM »
I've changed little fuzz factors, and now it worked in 3d... Still, sometimes it fails... This code is highly unreliable, but I don't know why... So my final conclusion is - use it only if necessary...

Thanks for no replies...
So long from me, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube