几何尺寸与公差论坛

 找回密码
 注册
查看: 120|回复: 2

per unit line profile when the considered feature is circle or ellipse.

[复制链接]
发表于 2008-11-12 21:21:52 | 显示全部楼层 |阅读模式
hi in?
[11:48:56 PM] Dan Zwick says: Hi Yanhua
[11:49:45 PM] yanhua Huang says: I start to working on per unit line profile when the considered feature is circle or ellipse.
[11:50:17 PM] Dan Zwick says: Ok. There's a function that finds the closest point on an ellipse.
[11:50:30 PM] yanhua Huang says: do you have a function to find meas point according to the given arc length.
[11:51:35 PM] Dan Zwick says: Hmmm, could be. Arclength on an ellipse is a special function, an "elliptic function."
[11:51:54 PM] Dan Zwick says: If I don't already have that I'm sure I could find one somewhere.
[11:57:48 PM] Dan Zwick says: double _DSFITEXPORT CDSFitEllipse2D::closest_point_on_ellipse(double ra, double rb, double x0, double y0,
                                                              double alpha, double z0, double w0,
                                                              double *t0, double *xc, double *yc)
[12:19:07 AM] yanhua Huang says: /*-------------------------------------------------------------------*/
/*  Find the closest point to a given point on an ellipse.           */
/*-------------------------------------------------------------------*/

double _DSFITEXPORT CDSFitEllipse2D::closest_point_on_ellipse(double ra, double rb, double x0, double y0,
                                                              double alpha, double z0, double w0,
                                                              double *t0, double *xc, double *yc)
the comment is right?
[12:20:26 AM] yanhua Huang says: I want to calculate ellipse lenth between two meas points.
[12:27:30 AM] Dan Zwick says: Well, first you need to find the closest points on the ellipse and their parameters. There is no closed form expression for arc length on an ellipse, other than in terms of certain special functions. It might suffice to use Gaussian quadrature to approximate the arc length, though.
[12:31:24 AM] yanhua Huang says: approximate computation  is OK
[12:31:59 AM] Dan Zwick says: Let me study this for a bit longer.
[12:33:44 AM] yanhua Huang says: By the way, recently I have a PR about the  low efficiency when compute line profile deviation.
[12:34:12 AM] Dan Zwick says: For straight lines?
[12:34:39 AM] yanhua Huang says: when the considered feature is scan....
[12:34:50 AM] Dan Zwick says: Does that mean it takes too long?
[12:35:07 AM] yanhua Huang says: try to work on it tomorrow
[12:35:38 AM] yanhua Huang says: PR256106 - Profile dimension calculation very slow
[12:35:49 AM] yanhua Huang says: (chuckle)
[12:35:52 AM] Dan Zwick says: How many points are there in that scan?
[12:36:01 AM] Dan Zwick says: Some people expect miracles.
[12:36:19 AM] yanhua Huang says: >900
[12:36:45 AM] Dan Zwick says: Is this profile per unit length?
[12:37:11 AM] yanhua Huang says: no, old problem...
[12:37:48 AM] Dan Zwick says: 2D or 3D?
[12:37:53 AM] yanhua Huang says: Have not investigated the issue, just verify the issue.
[12:38:59 AM] yanhua Huang says: Let me trace the code firstly  tomorrow. Just let you know....now
[12:39:17 AM] Dan Zwick says: Ok
[1:12:02 AM] Dan Zwick says: Take a look at ellipse_arc.cpp in MATHTOOL.
[1:13:58 AM] Dan Zwick says: This is used in HIT_HELP.CPP.
[1:16:58 AM] yanhua Huang says: which name is the function called?
[1:17:50 AM] Dan Zwick says: I suppose you need either ellipse_arc or ellipse_arc_inverse.
[1:19:48 AM] Dan Zwick says: It looks like I implemented all of that ellipse stuff, but I have completely forgotten it.
[1:20:08 AM] yanhua Huang says: (chuckle)perfect
[1:20:18 AM] Dan Zwick says: There are a bunch of other ellipse functions in hit_help.cpp.
[1:20:36 AM] Dan Zwick says: Which I apparently also wrote.
[1:21:31 AM] Dan Zwick says: In hit_help.cpp the task was to generate points equally spaced (according to arc length) on an ellipse.
[1:21:36 AM] yanhua Huang says:  t_theta = ellipse_arc_inverse(t_theta, s_start + p * (s_end - s_start), M, N);
how to set t_theta?
[1:22:24 AM] Dan Zwick says: It's an initial guess.
[1:23:02 AM] Dan Zwick says: If you are starting at the beginning set it to 0. After that set it to whatever the previous theta was.
[1:23:17 AM] Dan Zwick says: That is, assuming you are going to do it for all points at once.
[1:24:43 AM] Dan Zwick says: Keep in mind that these ellipse functions assume that the ellipse is in standard position. That is, it has  been rotated to the axes align with the x and y axes and the center is at the origin.
[1:24:58 AM] yanhua Huang says: Which feature should be created if I want to walk into ellipse_angle?
t:\V44B\HITS\HIT_HELP.CPP
[1:25:35 AM] Dan Zwick says: Also, it might make a difference where the larger semi axis is (along x or along y).
[1:27:04 AM] yanhua Huang says: max axis set to x?
[1:27:20 AM] Dan Zwick says: I'm not sure.
[1:29:03 AM] yanhua Huang says: thanks again, I will trace these code firstly  tomorrow.
[1:29:31 AM] Dan Zwick says: Ok. M and N are the semi-axes, but I'm not sure which is which.
[1:30:37 AM] Dan Zwick says:  theta = atan2(M * sin(t), N * cos(t))
[1:31:58 AM] Dan Zwick says: It looks like the equation of the ellipse here is
x = N cos(t), y = M sin(t), or (x/N)^2 + (y/N)^2 = 1.
[1:33:33 AM] Dan Zwick says: So N is along x, M is along y, but that doesn't necessarily mean that N > M.
[1:34:13 AM] yanhua Huang says: where is the comment?
[1:34:41 AM] yanhua Huang says: got it.
[1:35:09 AM] Dan Zwick says: Oh, there's also this:

// The following code is used by gen_ellipse_hits. It computes the polar angle of
// the point on the ellipse a proportion p of the way from the point on the perimeter
// corresponding to the polar angle start to the point on the perimeter corresponding
// to the polar angle end.
//
// NOTES.
// 1. The points on the ellipse are given in terms of the ellipse parameter t by
// (x,y) = (M cos(t), N sin(t)). The polar angle theta corresponding to (x,y) is
// arctan(y/x), which gives the conversion formula theta = arctan(N sin(t) / M cos(t)).
// 2. Arclength on an ellipse is expressed as an elliptic integral (of the second
// kind) with respect to the ellipse parameter t, which may be estimated to a high
// degree of accuracy. Once the arclength from start to end is computed, this integral
// has to be inverted in order to find the parameter t corresponding to the arclength
// of the desired point. This is done with Newton's Method.
[1:35:42 AM] Dan Zwick says: This is in hit_help.cpp.
[1:36:20 AM] Dan Zwick says: And that is definitely my English!
[1:38:09 AM] yanhua Huang says: (party) are there other notes?
[1:38:37 AM] Dan Zwick says: Just in the code.
[1:39:21 AM] Dan Zwick says: Funny I don't remember any of this. It was only a year ago. :S
[1:40:51 AM] yanhua Huang says: I try to look for the function using keyword = "ellipse" this afternoon,
[1:43:36 AM] yanhua Huang says: got >4000 matching lines results.
[1:44:59 AM] Dan Zwick says: Oh. I searched for elliptic integral.
[1:46:14 AM] yanhua Huang says: (F)I will go to |-)bed, good day,bye.
[1:46:36 AM] Dan Zwick says: Good night!
 楼主| 发表于 2008-11-12 21:22:35 | 显示全部楼层

回复: per unit line profile when the considered feature is circle or ellipse.

[12:07:10 AM] yanhua Huang says: hi in?
[12:58:25 AM] Ryan Gundry says: hi
[12:58:50 AM] yanhua Huang says: what time is it for you?
[12:58:58 AM] Ryan Gundry says: 10:00 AM
[12:59:23 AM] yanhua Huang says: Ryan,
How to get m_SplineCurveType (IDC_SCAN_PATH_CURVE_TYPE_TXT) from scan command?
[12:59:56 AM] Ryan Gundry says: It is not stored in that scan.  it is just used to create a path.
[1:01:05 AM] yanhua Huang says: is there other methods to know if scan is closed or opened?
[1:02:04 AM] yanhua Huang says: your scan path is a nurbs curve?
[1:05:32 AM] Ryan Gundry says: There are two types of scans LinearOpen and LinearClosed so you could differentiate by type, but LinearOpen can be closed if the user sets it up that way.
[1:06:03 AM] Ryan Gundry says: We just store the scan path, not the spline type used to create it.
[1:08:08 AM] yanhua Huang says: I do not know, if you did not store the spline type, when edit the scan, how did set the scan curve  type into scan dialog?
[1:09:06 AM] Ryan Gundry says: It just defaults to the last used type.
[1:14:39 AM] yanhua Huang says: got it, can you  add a new fuction to get m_SplineCurveType in CPCDscan?
[1:14:54 AM] Ryan Gundry says: What is it needed for?
[1:15:46 AM] yanhua Huang says: I have a task per unit line profile when the considered feature is scan.
[1:16:24 AM] yanhua Huang says: when try to fit scan to a curve, need set the curve if is closed or opened.
[1:17:05 AM] Ryan Gundry says: So you need to know if a scan is open or closed?
[1:17:15 AM] yanhua Huang says: yes
[1:20:58 AM] Ryan Gundry says: Is there a enhancement number?
[1:21:57 AM] yanhua Huang says: ER504978
[1:23:00 AM] yanhua Huang says: FYI------
[12:33:44 AM] yanhua Huang says: By the way, recently I have a PR about the  low efficiency when compute line profile deviation.
[12:34:12 AM] Dan Zwick says: For straight lines?
[12:34:39 AM] yanhua Huang says: when the considered feature is scan....
[12:34:50 AM] Dan Zwick says: Does that mean it takes too long?
[12:35:07 AM] yanhua Huang says: try to work on it tomorrow
[12:35:38 AM] yanhua Huang says: PR256106 - Profile dimension calculation very slow
[12:35:49 AM] yanhua Huang says: (chuckle)
[12:35:52 AM] Dan Zwick says: How many points are there in that scan?
[12:36:01 AM] Dan Zwick says: Some people expect miracles.
[12:36:19 AM] yanhua Huang says: >900
[12:36:45 AM] Dan Zwick says: Is this profile per unit length?
[12:37:11 AM] yanhua Huang says: no, old problem...
[12:37:48 AM] Dan Zwick says: 2D or 3D?
[12:37:53 AM] yanhua Huang says: Have not investigated the issue, just verify the issue.
[12:38:59 AM] yanhua Huang says: Let me trace the code firstly  tomorrow. Just let you know....now
 楼主| 发表于 2008-11-12 21:23:38 | 显示全部楼层

回复: per unit line profile when the considered feature is circle or ellipse.

[8/25/2008 8:14:11 PM] yanhua Huang says: hi in?
[8/25/2008 10:46:49 PM] Dan Zwick says: Hi Yanhua
[8/25/2008 10:48:46 PM] yanhua Huang says: Hi Yanhua,
Straightness per unit length is section 6.4.1.1.4 in Y14.5M-1994. Figure 6.4 shows how it is applied. The code is in the file Straightness2D.cpp in the pcdsfit project of 4.4B. You just have to give a length (in mm or inches) and a line scan as a set of 2D points in a double ** array and it computes the maximal straightness value along the line for each segment of that length. I would allocate the array using pdMatrix or newMatrix from the pcdsfit dll, and delete it using deleteMatrix.
Bye,
Dan
Do you know which function Dan mentioned in straightness2D.cpp?
[8:19:30 PM] Donald Turcotte said: In file V44B\PCDSFIT\SOURCE\Straightness2d.cpp there is a straightness2D(...) method
[8:21:49 PM] yanhua Huang said: it seems 2D straightness?
[8/25/2008 10:48:57 PM] Dan Zwick says: I'm in Arizona. We have Mountain Standard Time the entire year, which mean that we currently have the same time as California.
[8/25/2008 10:49:37 PM] Dan Zwick says: Yes, that's it.
[8/25/2008 10:50:42 PM] yanhua Huang says: we should support 3D straightness with per unit length.
[8/25/2008 10:51:22 PM] yanhua Huang says: are you in GMT -7?
[8/25/2008 10:52:40 PM] yanhua Huang says: could you write 3D straightness algorithm with per unit length?
[8/25/2008 10:54:38 PM] Dan Zwick says: I think straightness is a 2D tolerance.
[8/25/2008 10:55:25 PM] yanhua Huang added Donald Turcotte to this chat
[8/25/2008 10:55:25 PM] Click here to view remainder of this chat.
[8/25/2008 10:55:25 PM] Dan Zwick says: Yes, GMT-7.
[9/1/2008 9:21:24 PM] yanhua Huang says: hi in?
[9/2/2008 12:27:57 AM] Dan Zwick says: Hi Yanhua, I'm in now.
[9/2/2008 12:31:09 AM] Dan Zwick says: I just got your email. I'll download 4.4B and build it. The last time I tried 4.4B it got into an infinite loop, though (nothing to do with straightness). Hopefully that has been fixed.
[9/2/2008 12:31:22 AM] Dan Zwick says: BTW, today is a national holiday in the US.
[9/2/2008 12:33:18 AM] yanhua Huang says: thanks
[9/2/2008 12:33:54 AM] yanhua Huang says: _DSFITEXPORT double straightness2D(int n, double **Pts, double len/*=0*/)
is "n" point number? or n = point number X 3?
[9/2/2008 12:34:44 AM] Dan Zwick says: n is the total number of points
[9/2/2008 12:35:21 AM] Dan Zwick says: So Pts would be an n x 2 array.
[9/2/2008 12:37:47 AM] yanhua Huang says: can you re-use your code about sliding window for straightness of axis with per unit?
[9/2/2008 12:38:52 AM] Dan Zwick says: Probably. There would have to be some changes, though...
[9/2/2008 12:41:09 AM] yanhua Huang says: _DSFITEXPORT double straightness2D(int n, double **Pts, double len/*=0*/)
_DSFITEXPORT double straightness2D(int n, double **Pts, double len/*=0*/)

for (int jj = jprev + 2; jj < n && jj < jprev + 12; jj++)
>What role is "12"?
[9/2/2008 12:42:59 AM] Dan Zwick says: Good question. Let me take a look.
[9/2/2008 12:47:09 AM] Dan Zwick says: I don't remember why that's there. Let me think about that for a couple of minutes.
[9/2/2008 12:47:30 AM] yanhua Huang says: ok
[9/2/2008 12:54:16 AM] Dan Zwick says: Well, it's searching for the first point after the current point that is a distance len from the current point. This can be done efficiently by a binary search, but since it's likely that only the next few points have to be checked, it first checks the next 10 points before starting the binary search. If it succeeds it skips the binary search.
[9/2/2008 12:54:50 AM] Dan Zwick says: I just chose that number at random.
[9/2/2008 12:57:21 AM] Dan Zwick says: Some of the changes that have to be made: ddist2 is just 2D distance. This will have to be replaced by ddist for 3D points.
[9/2/2008 12:59:36 AM] Dan Zwick says: The call to MinMaxLine will have to be replaced by a call to

double _DSFITEXPORT Line3D(int npts, double **xm, double *X0, double *N,
double &length, e_approx approx/*=lsq*/)

with approx = minmax.
[9/2/2008 1:00:18 AM] Dan Zwick says: Also, I think you need at least 4 points for a 3D minmax line.
[9/2/2008 1:02:10 AM] Dan Zwick says: Actually, it would be better to copy the code in Line3D but use the option useInitialInfo so that it uses the previous values of X0 and N to compute the next line.
[9/2/2008 1:04:25 AM] Dan Zwick says: That would look something like this:

CDSFitVals vals;
CDSFitOptions options;
e_ftype ftype = t_line3D;

options.useInitialInfo = true;
copyVector(3, X0, vals.X0);
copyVector(3, N, vals.N);

// Invoke DSFit for the line.
int ret = DSFit(approx, ftype, options, npts, 3, xm, NULL, vals);

etc.
[9/2/2008 1:05:33 AM] Dan Zwick says: Oops, you also need

e_approx approx = minmax;
[9/2/2008 1:05:51 AM] yanhua Huang says:
which role is useInitialInfo?
[9/2/2008 1:06:12 AM] Dan Zwick says: It tells DSFit to use the values of X0 and N as initial values.
[9/2/2008 1:07:41 AM] Dan Zwick says: Otherwise it will compute its own initial values. This is usually a good thing, but in this case we expect the next line to be very close to the previous line. Except for the first one, of course.
[9/2/2008 1:08:05 AM] Dan Zwick says: Using the previous values should speed things up.
[9/2/2008 1:08:45 AM] yanhua Huang says: after I add some functions for straightness with per unit, could you help to view these code?
[9/2/2008 1:08:53 AM] Dan Zwick says: Sure.
[9/2/2008 1:09:13 AM] yanhua Huang says: ok, thanks very much.
[9/2/2008 1:09:28 AM] Dan Zwick says: yw
[9/2/2008 1:09:38 AM] yanhua Huang says: oh, another question about sort points
[9/2/2008 1:10:49 AM] yanhua Huang says: for a series of circle centroids, how to sort those points? need we eliminate some points?
[9/2/2008 1:11:17 AM] Dan Zwick says: Can't we just require that they already be in order?
[9/2/2008 1:11:57 AM] Dan Zwick says: How many points do you expect to get?
[9/2/2008 1:13:39 AM] yanhua Huang says: hit points, now just using a constuct_BF_LINE example of 5 points
[9/2/2008 1:15:13 AM] Dan Zwick says: Here's one way to do it: fit a least squares line to the points. Suppose the least squares line has X0 and N. Project each of the points onto the line and sort the points according to their projections. That is, compute ti = (xi - X0) dot N and sort the points so that the ti are in increasing order.
[9/2/2008 1:15:46 AM] Dan Zwick says: Does that make sense?
[9/2/2008 1:16:22 AM] yanhua Huang says: when user try to use 5 circle centers to construct a 3D line, the 3D construct_BF_LINE's points sometime is not inorder.
[9/2/2008 1:16:40 AM] Dan Zwick says: Ok, then you'll have to rearrange them.
[9/2/2008 1:17:44 AM] Dan Zwick says: One thing you could do is transform things so that the least squares line is the z-axis and sort the points by z-coordinate.
[9/2/2008 1:18:40 AM] Dan Zwick says: This is not really necessary, but it's easier to program.
[9/2/2008 1:20:48 AM] yanhua Huang says: got it, thanks
[9/2/2008 1:21:26 AM] Dan Zwick says: np
[9/2/2008 1:21:45 AM] Dan Zwick says: Let me know if you run into any difficulties.
[9/2/2008 1:22:39 AM] yanhua Huang says: OK, thanks again
[9/2/2008 1:22:48 AM] Dan Zwick says: bye
[9/2/2008 1:23:41 AM] yanhua Huang says: bye
[9/2/2008 1:25:05 AM] Dan Zwick says: I still can't run that part program in 4.4B. It gets into an infinite loop while loading. Sorry!
[9/2/2008 1:25:51 AM] Dan Zwick says: I don't think it has anything to do with straightness. I've filed a PR, but nobody has looked at it yet.
[9/2/2008 1:26:40 AM] yanhua Huang says: which number is your filed PR?
[9/2/2008 1:27:41 AM] Dan Zwick says: 256796
[9/2/2008 1:28:09 AM] Dan Zwick says: It never exits DoAutoSaveCheck().
[9/2/2008 1:30:11 AM] Dan Zwick says: Hmmm, maybe I can bypass that check...
[9/2/2008 1:31:12 AM] yanhua Huang says: oh, let me download V44B, I have not updated pcdims V44B for four days.
[9/2/2008 1:31:53 AM] Dan Zwick says: Ok, good luck.
[9/2/2008 1:38:33 AM] Dan Zwick says: I was able to get it to run by commenting out the call to DoAutoSaveCheck. That's on line 3549 in pcdlrn.cpp.
[9/2/2008 1:39:36 AM] Dan Zwick says: Also, I had to change the tip names. T1A0B0 needs to be "T1A0.B0.".
[9/2/2008 1:39:45 AM] Dan Zwick says: That's the way it is in the probe file.
[9/2/2008 1:40:44 AM] yanhua Huang says: for construct_BF_line, tip radii = 0,
[9/2/2008 1:41:09 AM] yanhua Huang says: without radii compensation for construct_BF_line
[9/2/2008 1:41:14 AM] Dan Zwick says: It wouldn't execute until I fixed that.
[9/2/2008 1:41:43 AM] Dan Zwick says: It said "Illegal tip command."
[9/2/2008 1:42:27 AM] yanhua Huang says: you can change tip to your existed proble
[9/2/2008 1:44:14 AM] Dan Zwick says: Well, anyway I'm now getting the same values that you got.
[9/2/2008 1:44:29 AM] yanhua Huang says:
[9/2/2008 1:44:45 AM] Dan Zwick says: So now I can try to find out why it's not working.
[9/2/2008 1:45:16 AM] yanhua Huang says: (handshake)I go to sleep
[9/2/2008 1:45:30 AM] yanhua Huang says: good day, bye
[9/2/2008 1:45:36 AM] Dan Zwick says: Bye
[9/9/2008 10:25:16 PM] yanhua Huang says: hi in?
[9/9/2008 10:39:19 PM] Dan Zwick says: Hi Yanhua
[9/9/2008 10:41:23 PM] yanhua Huang says: How to associate cylinder (lsq)?
[9/9/2008 10:42:27 PM] Dan Zwick says: I don't understand what you mean by "associate." Can you explain a bit more for me?
[9/9/2008 10:42:41 PM] yanhua Huang says: best fit
[9/9/2008 10:43:06 PM] yanhua Huang says: associate means fit
[9/9/2008 10:43:13 PM] Dan Zwick says: Do you want to know how to call DSFit to compute a best fit cylinder?
[9/9/2008 10:43:19 PM] yanhua Huang says: yes
[9/9/2008 10:44:41 PM] Dan Zwick says: Do you need to compensate for the tip radius or have multiple tips? If not you can just call the function

double _DSFITEXPORT Cylinder(int npts, double **xm, double **T, double *X0,
double *N, double &R, double &length, e_approx approx/*=lsq*/)
[9/9/2008 10:45:20 PM] Dan Zwick says: If you have tip radii then you'll have to call DSFit with the appropriate arguments...
[9/9/2008 10:51:56 PM] Dan Zwick says: This generally means declaring

CDSFitVals fitVals;
CDSFitOptions fitOptions;

Then setting the appropriate options, if any, and filling in the appropriate initial values, if you have them, then calling DSFit.

You can look in best_cyl.cpp to get an idea. After calling DSFit the computed values can be read out of fitVals.
[9/9/2008 10:54:24 PM] Dan Zwick says: A typical call to DSFit looks like this

RetVal = DSFit(lsq, t_cyl, fitOptions, num_inputs, 3, pdPoints, pdVectors, fitVals, radii ;

If you have good hit vectors that are approximately normal to the surface then set fitOptions.vectors to true.
[9/9/2008 10:54:51 PM] yanhua Huang says: double _DSFITEXPORT Cylinder(int npts, double **xm, double **T, double *X0,
double *N, double &R, double &length, e_approx approx/*=lsq*/)
>double **T
->vector set of measured points?
[9/9/2008 10:55:45 PM] Dan Zwick says: xm are the measured points and T are the hit vectors, assumed to be approximate normals.
[9/9/2008 10:58:23 PM] Dan Zwick says: You can use NULL for T if you don't have good hit vectors. This is better than using bad vectors.
[9/9/2008 11:00:26 PM] Dan Zwick says: If you have good initial values you can set the option useInitialInfo to true and enter the values in fitVals.
[9/9/2008 11:00:55 PM] Dan Zwick says: (but only if you invoke DSFit directly)
[9/9/2008 11:01:38 PM] Dan Zwick says: However, DSFit can usually compute good initial values itself.
[9/9/2008 11:04:46 PM] yanhua Huang says: I sent a email about this.
[9/9/2008 11:05:18 PM] Dan Zwick says: I just got it. I'll take a look.
[9/9/2008 11:05:46 PM] yanhua Huang says: I try to get centroid and axis vector when cylinder(lsq).
[9/9/2008 11:09:27 PM] Dan Zwick says: You realize that straightness uses a minmax line rather than a least squares line. So the axis of the least squares cylinder will differ slightly from the line computed for straightness.
[9/9/2008 11:10:15 PM] yanhua Huang added Donald Turcotte to this chat
[9/10/2008 1:16:29 AM] Click here to view remainder of this chat.
[9/10/2008 1:16:29 AM] yanhua Huang says: when consider feature is cylinder,
[1:04:42 AM] yanhua Huang says: the default tolerance zone of cylinder is cylindrical zone.
[1:07:54 AM] yanhua Huang says: when fit a 3D line, CDSFitVals.distance is a radius distance or planar projection distance?
[9/10/2008 1:47:14 AM] Dan Zwick says: Even though you're offline, I'm going to make some notes here about what I find. I'll also send them in an email.
[9/10/2008 1:50:31 AM] Dan Zwick says: First of all, the function CalculateSectionCentroids() is extremly inefficient. If the points are already in order, then it will work fine, but if not then it can take a long time. The most efficient way to do it is to first sort the points by z-coordinate (after transforming). This is equivalent to sorting by projection onto the cylinder axis. Once the points are sorted they can be easily divided into groups for the individual circles. Once this is done, it is no longer necessary to sort the circle centroids since they will already be in order.
[9/10/2008 1:52:00 AM] Dan Zwick says: So the function that determines the section circles can be combined with the function that sorts the centroids into one, simpler function.
[9/10/2008 2:35:02 AM] Dan Zwick says: nSecondPtIndex is just the number of points. This is confusing.
[9/10/2008 4:50:41 AM] Dan Zwick says: Maybe it should be called nNumPoints or something.
[9/10/2008 5:10:14 AM] Dan Zwick says: In general, things look very complicated, in part because things keep getting computed or recomputed that are not necessary. Please try to simplify the logic. It is not necessary to compute a bunch of cylinders in order to use their axes. I think the procedure should be:

1. Use the computed cylinder axis to sort the data points and subdivide them for the section circles.
2. Compute *3D circles* for each of the sections. If you compute 2D circles they will be projected onto the current workplane. Even if you have transformed the cylinder axis to the z-axis, this will not give you the "derived median line" of the cylinder. See fig. 6-4 in Y14.5M.
3. The centroids of these section circles should already be in order, so you don't have to sort them again.
4. For straightness, compute a minmax 3D line for all the section circle centroids. Twice the minmax error is the straightness. You don't need to recompute the deviations.
5. For straightness per unit length, you can either slide the window along the cylinder axis as you are doing (that is, use the projection lengths) or just compute the distance from the first point in a segment to the last point (as we do for 2D straightness). I'm not sure which is better.
6. Compute a minmax 3D line for the centroids within the window and record the straightness for that line.

There is a lot of copying of data going on. Wouldn't it be possible to transform the data once and continue to use the transformed data?
[9/10/2008 5:34:27 AM] Dan Zwick says: I'm not sure why the per unit length straightness is coming back 0. The values computed by CalculateAxisDeviation are on the order of 1.e-11. Perhaps you should be doing a 3D calculation instead of a 2D one. In any case, you shouldn't be computing the deviations yourself, and certainly not from a lsq line. You should be computing a minmax line and reporting the minmax error.
[9/10/2008 10:20:19 AM] yanhua Huang says: in?
[9/10/2008 12:31:59 PM] Dan Zwick says: Hi Yanhua, I'm back if you're still there.
[9/10/2008 12:33:04 PM] yanhua Huang says: I will use 3D line (maxmin) to compute axis straightness of cylinder.
[9/10/2008 12:34:01 PM] yanhua Huang says: now need not BF-cylinder (lsq),
[9/10/2008 12:35:53 PM] Dan Zwick says: That should help. Also, using 3D circles for the section circles might help. If you need help with 3D circles let me know. I don't think tips are supported. If you need to compensate for tips you might consider just computing a best fit plane and then computing the best circle in that plane. This is not quite the same as a 3D circle, but it should be good enough.
[9/10/2008 12:35:58 PM] yanhua Huang says: change pcdims V44B from offline to simulator, cylinder function is working for my another test part program now. It seems there are error hit points in cylinder1(auto cylinder).
[9/10/2008 12:36:13 PM] Dan Zwick says: Ah
[9/10/2008 12:36:49 PM] Dan Zwick says: Then it might be a good idea to send me the debug file along with the part program if you want me to review your code.
[9/10/2008 12:37:25 PM] yanhua Huang says: ok
[9/10/2008 12:39:29 PM] Dan Zwick says: You're doing a good job. This is a lot for you to learn in a short period of time.
[9/10/2008 12:40:49 PM] Dan Zwick says: There's still so much I don't know about PC-DMIS. Fortunately, I can usually ask Andy.
[9/10/2008 12:43:50 PM] yanhua Huang says: I want to know more knowledge about fit, could you tell me refrence book names about best fit?
[9/10/2008 12:47:32 PM] Dan Zwick says: I don't know of any recent ones on best fitting. There are books on optimization and books on computational linear algebra, but I can't think of any on least squares and minimax best fitting. I'll see if I can find anything.
[9/10/2008 12:50:42 PM] yanhua Huang says: thanks,
I will simplify the logic for axis of cylinder
[9/10/2008 12:50:56 PM] Dan Zwick says: Ok, ttyt
[9/10/2008 12:51:42 PM] yanhua Huang says: if I completed these code, I will sent my test part program and ask you view these code.
[9/10/2008 12:51:57 PM] Dan Zwick says: Sure, np.
[9/10/2008 12:52:13 PM] yanhua Huang says: good night, bye
[9/10/2008 12:52:56 PM] Dan Zwick says: Good night!
[9/11/2008 10:09:02 PM] yanhua Huang says: hi in?
[9/11/2008 10:09:34 PM] Dan Zwick says: Hi Yanhua
[9/11/2008 10:12:23 PM] yanhua Huang says: I remember you said that need at least 4 points for a 3D minmax line. Could you tell me the reason for this?
[9/11/2008 10:13:27 PM] Dan Zwick says: Sorry, that was wrong. If there are only three points then the 3D minmax line is the same as the 2D minmax line in the plane of the three points.
[9/11/2008 10:15:10 PM] Dan Zwick says: Of course, if there are only two points then there is a unique line.
[9/11/2008 10:16:15 PM] Dan Zwick says: In fact, no matter now many points you have, if they are coplanar then the 3D best fit is the same as the 2D best fit in that plane.
[9/11/2008 10:17:16 PM] yanhua Huang says: Don found one issue.
FCFSTRA2 just has 3 points in per unit window. line deviation of 3 Points in per unit window is slightly larger than line deviation of 4 points in the whole window.
I sent email about this issue.
[9/11/2008 10:18:27 PM] Dan Zwick says: Hmmm, if you add points the error should increase, not decrease.
[9/11/2008 10:21:53 PM] Dan Zwick says: I'll take a look.
[9/11/2008 10:21:58 PM] yanhua Huang says: yes, I sent don's test PP and probe file via email.
When I use don’s probe file, I can verify this issue.
[9/11/2008 10:22:33 PM] Dan Zwick says: Ok, I'll have to download and build 4.4B first, though.
[9/11/2008 10:22:38 PM] yanhua Huang says: thanks
[9/11/2008 10:22:45 PM] Dan Zwick says: yw
[9/17/2008 12:19:57 AM] yanhua Huang says: hi in?
[9/17/2008 12:20:39 AM] Dan Zwick says: Hi Yanhua, I have a conference call right now. I'm in the process of answering your email, though.
[9/17/2008 12:21:14 AM] yanhua Huang says: ok
[9/19/2008 1:11:23 AM] yanhua Huang says: hi in?
[9/19/2008 2:40:19 AM] Dan Zwick says: Hi Yanhua, I'm back
[9/19/2008 2:42:52 AM] yanhua Huang says: Dan,
What definition is per parameter?
Which coeffs is fit_curve? Is cubic spline?
Thanks in advance.
double arc_inverse(int m, int ndim, double *cx, double *cy, double *cz, double *t, double u, double tau)
nErrorCode = fit_curve(m_NumPoints, m_FitPoints, &m_NumCPs, &pdCPs, &pdKnots, m_Dim, m_bUseThinTol, thinParm);

Yanhua
[9/19/2008 2:43:13 AM] Dan Zwick says: I was just going to answer that email
[9/19/2008 2:43:23 AM] Dan Zwick says: This is a cubic spline curve.
[9/19/2008 2:44:05 AM] yanhua Huang says: (party)
[9/19/2008 2:44:09 AM] Dan Zwick says: The control points (which are the coefficients) are points in 3D.
[9/19/2008 2:45:07 AM] yanhua Huang says: points number + 3 = knots number?
[9/19/2008 2:45:15 AM] Dan Zwick says: So the form of the curve is Sum { Ci Bi(t) }, where the Ci are 3D points and the Bi(t) are B-splines.
[9/19/2008 2:46:33 AM] Dan Zwick says: The knots are t[0] <= ...<= t[m+4],
m >= 3, for cubic splines. The domain of a cubic spline is
[t[3],t[m+1]]. The cubic B-spline N_i has support
[t,t[i+4]]. Thus, there are m+1 nonzero B-splines in
[t[3],t[m+1]]: N_0,...,N_m; hence, a spline has m+1
coefficients. A coefficient C_i only influences the spline in
the interval (t,t[i+4]). The spline curve at a parameter in
(t[l],t[l+1]) is completely determined by the 4 control points
C_{l-3},...,C_l.
[9/19/2008 2:47:47 AM] Dan Zwick says: This is for an open spline curve.
[9/19/2008 2:48:27 AM] yanhua Huang says: I saw B-spline formula, I open my graphic book.
[9/19/2008 2:49:34 AM] Dan Zwick says: So the knots are t[0],...,t[m+4], but t[0] = ... = t[3] and t[m+1] = ... = t[m+4]. Usually we only keep the distinct knots, so those are t[3],...,t[m+1].
[9/19/2008 2:50:25 AM] Dan Zwick says: There are m+1 terms, corresponding to m+1 coefficients.
[9/19/2008 2:52:02 AM] Dan Zwick says: The control points (coefficients) are C[0],...,C[m].
[9/19/2008 2:53:12 AM] Dan Zwick says: So that's cx, cy, and cz from 0 to m.
[9/19/2008 2:55:06 AM] Dan Zwick says: Also, note that the parameter t is in the interval [t[3],t[m+1]]. This is the interval [a,b] for the parameter t.
[9/19/2008 2:55:58 AM] yanhua Huang says: what is a and b?
[9/19/2008 2:56:10 AM] Dan Zwick says: The domain of the spline function.
[9/19/2008 2:56:21 AM] yanhua Huang says: oh
[9/19/2008 2:56:30 AM] Dan Zwick says: It's a function from R into R^3.
[9/19/2008 2:56:42 AM] Dan Zwick says: Assuming it's a 3D curve.
[9/19/2008 2:59:57 AM] yanhua Huang says: what is "tau"?
[9/19/2008 3:00:07 AM] Dan Zwick says: A lot of people I know have The NURBS book by Piegl and Tiller. It seems to be pretty good for splines.
[9/19/2008 3:01:16 AM] Dan Zwick says: tau is the parameter of the point on the curve where the arclength from the start is equal to the value u.
[9/19/2008 3:01:40 AM] Dan Zwick says: That is, the arclength from t[3] to tau is u.
[9/19/2008 3:01:48 AM] yanhua Huang says: point index?
[9/19/2008 3:01:54 AM] Dan Zwick says: You input u and you get back tau.
[9/19/2008 3:02:20 AM] Dan Zwick says: If you want the actual point on the curve you have to evaluate it at tau.
[9/19/2008 3:02:41 AM] yanhua Huang says: actual length?
[9/19/2008 3:02:48 AM] Dan Zwick says: Yup.
[9/19/2008 3:03:39 AM] yanhua Huang says: what is m_bUseThinTol?
[9/19/2008 3:05:06 AM] Dan Zwick says: It has to do with constructing a spline function.
[9/19/2008 3:05:55 AM] yanhua Huang says: what is thinParm?
[9/19/2008 3:06:06 AM] Dan Zwick says: Same kind of thing.
[9/19/2008 3:06:26 AM] yanhua Huang says: oh, got it , thanks very much.
[9/19/2008 3:06:30 AM] Dan Zwick says: They both indicate how many of the original points to use for the knots.
[9/19/2008 3:06:47 AM] Dan Zwick says: The thinParm says use about that percentage of them.
[9/19/2008 3:06:59 AM] yanhua Huang says: oh
[9/19/2008 3:08:15 AM] Dan Zwick says: Generally speaking, when you construct an interpolating spline or an approximating spline, the first thing to do is to decide on the knots. Then they usually are fixed for the rest of the process. The thinning tolerance and the thinning parameter indicate how many knots to use.
[9/19/2008 3:09:20 AM] Dan Zwick says: Do you have to construct the splines yourself? Or do they already exist when you do the profile?
[9/19/2008 3:10:57 AM] yanhua Huang says: I try to construct a spline, if not, I have to deal with line, circle, ....
[9/19/2008 3:11:46 AM] Dan Zwick says: I don't understand. Isn't this for freeform curves?
[9/19/2008 3:12:10 AM] yanhua Huang says: use can create profile on features excluding point_cloud
[9/19/2008 3:13:01 AM] Dan Zwick says: Well, I wouldn't use a spline curve or surface for a geometric element. Just for freeform curves and surfaces.
[9/19/2008 3:14:55 AM] Dan Zwick says: For lines and planes we already have straightness and circularity.
[9/19/2008 3:19:40 AM] yanhua Huang says: 1) construct b-spline via measured points
2) slide forward cosntructed b-spline
3)find the closet nominal point relative to measured point
4)deviation = dot (hint vector, nominalPt(i) - measuredPt(i) )
[9/19/2008 3:21:13 AM] Dan Zwick says: Yes. But only for curves.
[9/19/2008 3:21:40 AM] Dan Zwick says: That is all possible, although it may be a bit slow.
[9/19/2008 3:21:56 AM] Dan Zwick says: The only problem is with (1).
[9/19/2008 3:22:36 AM] Dan Zwick says: What you need is a least squares spline fit. How well it fits will depend in part on the number of knots.
[9/19/2008 3:23:37 AM] Dan Zwick says: With the right number of knots you can compute an interpolating spline. That's a spline that passes through every data point. Then the error is going to be 0.
[9/19/2008 3:24:41 AM] Dan Zwick says: The more knots you have, the better a fit you will (usually) get. Do you see the problem here?
[9/19/2008 3:25:21 AM] Dan Zwick says: So the question is, which approximating spline should be used to evaluate the profile?
[9/19/2008 3:28:35 AM] Dan Zwick says: ...and the answer is, we want one that best reveals the underlying feature (in a least squares sense). After all, what we really want are the deviations from the actual curve, not some computed curve.
[9/19/2008 3:29:33 AM] Dan Zwick says: So what I think we should use is the smoothing spline that is used in computing the spline filter.
[9/19/2008 3:31:48 AM] yanhua Huang says: use computed curve to decide slide direction and computing arc_length.
[9/19/2008 3:32:07 AM] Dan Zwick says: That's computed in gcvnd.cpp in the dblstar library.
[9/19/2008 3:32:44 AM] Dan Zwick says: Yeah. The problem is that I've never used that smoothing spline for computing arclength. It might be in a different format.
[9/19/2008 3:35:24 AM] Dan Zwick says: There is a function for computing the spline value. It had code for computing the derivative too, but it's commented out.
[9/19/2008 3:36:08 AM] Dan Zwick says: Maybe we should discuss this with Andy. That always seems to help.
[9/19/2008 3:36:20 AM] Dan Zwick added Andy Roberts to this chat
[10/27/2008 10:09:18 PM] Click here to view remainder of this chat.
[10/27/2008 10:09:18 PM] yanhua Huang says: hi in?
[10/27/2008 10:30:16 PM] Dan Zwick says: Hi Yanhua
[10/27/2008 10:30:55 PM] yanhua Huang says: What difference between CPCDcurve and CDSFitCurve?
[10/27/2008 10:31:52 PM] Dan Zwick says: I guess one is a DSFit class and one is a PC-DMIS class.
[10/27/2008 10:32:58 PM] yanhua Huang says: Could you help me to review my changed code for item 11 of TK104539?
[10/27/2008 10:33:42 PM] Dan Zwick says: Ok. Do you have a part program that you use for testing?
[10/27/2008 10:33:50 PM] yanhua Huang says: yes
[10/27/2008 10:34:03 PM] yanhua Huang says: I sent you via email right now
[10/27/2008 10:34:25 PM] yanhua Huang says: don R gave me a test PP last week
[10/27/2008 10:34:38 PM] Dan Zwick says: Ok, I'll give it a look this morning.
[10/27/2008 10:35:01 PM] Dan Zwick says: Is it a 4.3B part program?
[10/27/2008 10:35:12 PM] yanhua Huang says: V44B
[10/27/2008 10:35:23 PM] Dan Zwick says: Oh. Then I'll have to build 4.4B first.
[10/27/2008 10:37:17 PM] Dan Zwick says: That will take a while.
[10/27/2008 10:37:54 PM] Dan Zwick says: Did you say you sent me that pp? I haven't received it yet.
[10/27/2008 10:40:23 PM] yanhua Huang sent file "10212008_01a.zip" to members of this chat
[10/27/2008 10:41:06 PM] Dan Zwick says: Thanks
[10/27/2008 10:42:03 PM] Dan Zwick says: I'm downloading now. I'll build 4.4B and let you know how it went.
[10/27/2008 10:43:45 PM] yanhua Huang says: thanks.
double arc_inverse(int m, int ndim, double *cx, double *cy, double *cz,
double *t, double u, double tau)
{
int i;
double f, fprime, t0, del_tau, eps = 1.e-4;

t0 = t[3];
for (i = 0; i < 30; i++)
{
fprime = spline_func(m, ndim, cx, cy, cz, t, tau);
if (fprime == 0.)
break;
f = compute_length(m, ndim, cx, cy, cz, t, t0, tau) - u;
del_tau = f / fprime;
tau -= del_tau;
if (fabs(del_tau) < eps)
break;
}

if (tau < t0)
return t0;
if (tau > t[m+1])
return t[m+1];

return tau;

} /* end arc_inverse */
for (i = 0; i < 30; i++)
What means 30 (loop)
[10/27/2008 10:45:13 PM] Dan Zwick says: That's Newton's method.
[10/27/2008 10:45:34 PM] yanhua Huang says: oh
[10/27/2008 10:46:37 PM] Dan Zwick says: It solves for tau iteratively. 30 is the maximal number of iterations.
[10/27/2008 10:47:31 PM] Dan Zwick says: Ignoring the other arguments, the function to solve for is f(tau) = length(tau) - u.
[10/27/2008 10:48:24 PM] Dan Zwick says: The derivative is easy since the length is an integral. By the fundamental theorem of calculus the derivative of the integral is its integrand (the thing it's integrating) evaluated at tau.
[10/27/2008 10:48:42 PM] Dan Zwick says: That's fprime.
[10/27/2008 10:48:50 PM] yanhua Huang says: #define DEFAULT_THIN_TOL 0.01
is its unit mm or inch? set m_ThinTol = 0.01
is the tolerance value OK when try to fit scan as curve?
[10/27/2008 10:49:54 PM] Dan Zwick says: That's a good question. The thinning tolerance is a distance, so maybe it should have been multiplied by global_units.
[10/27/2008 10:50:44 PM] Dan Zwick says: But generally speaking, the larger the tolerance the fewer knots and the smaller the tolerance the more knots.
[10/27/2008 10:51:17 PM] Dan Zwick says: More knots means more parameters, and a better fit. But it also means that it takes longer to compute.
[10/27/2008 10:52:04 PM] Dan Zwick says: The thinning tolerance is used for approximating data by splines.
[10/27/2008 10:52:20 PM] Dan Zwick says: Not for interpolating all of the data.
[10/27/2008 10:52:40 PM] Dan Zwick says: If you set the thinning tolerance to 0 it will interpolate.
[10/27/2008 10:53:27 PM] yanhua Huang says: 3-bspine interpolate?
[10/27/2008 10:53:29 PM] Dan Zwick says: The thinning tolerance and the other thinning parameter determine how many of the original data points to use as knots.
[10/27/2008 10:53:32 PM] Dan Zwick says: Yes.
[10/27/2008 10:54:06 PM] Dan Zwick says: The thinning parameter says what percentage (approximately) of the points to use as knots.
[10/27/2008 10:54:56 PM] yanhua Huang says: for scan, is it better to use interpolate or fit with tolerance?
[10/27/2008 10:55:21 PM] Dan Zwick says: Depends on what the purpose is.
[10/27/2008 10:57:00 PM] Dan Zwick says: Why do you need to fit a curve to do straightness per unit length?
[10/27/2008 10:57:15 PM] yanhua Huang says: for per unit line profile on scan, just slide per unit window based the fited curve
[10/27/2008 10:57:22 PM] Dan Zwick says: The points are already in order.
[10/27/2008 10:57:36 PM] Dan Zwick says: If they weren't you wouldn't be able to fit the curve.
[10/27/2008 10:57:38 PM] yanhua Huang added Donald Turcotte to this chat
[10/30/2008 9:10:09 PM] Click here to view remainder of this chat.
[10/30/2008 9:10:09 PM] yanhua Huang says: hi in?
[10/30/2008 11:35:54 PM] Dan Zwick says: Hi Yanhua, sorry I had a conference call this morning. What's up?
[10/30/2008 11:36:53 PM] yanhua Huang says: double curvdst(int nshape, double *coeffs, int m, double *t, int ndim, double *Pm, double *P0, double t_in, double *t0, int closed)
questions about curvdst
[10/30/2008 11:37:06 PM] Dan Zwick says: Ok
[10/30/2008 11:37:25 PM] yanhua Huang says: if open curve, closed = ?
[10/30/2008 11:37:49 PM] Dan Zwick says: 0 I would imagine... let me check
[10/30/2008 11:39:07 PM] Dan Zwick says: Yes
[10/30/2008 11:40:50 PM] yanhua Huang says: How to set nshape? is it OK set nshape = 0?
[10/30/2008 11:41:02 PM] Dan Zwick says: Yes, it's not used.
[10/30/2008 11:42:53 PM] yanhua Huang says: double *coeffs = pdVector(m_Dim *(m_NumPoints + 1));
for(long i = 0; i < m_NumPoints; i++)
{
coeffs = m_CPs[0];
coeffs[m_NumPoints+1+i] = m_CPs[1];
coeffs[2*m_NumPoints+2+i] = m_CPs[2];
}
Is number of coeffs right?
[10/30/2008 11:46:42 PM] Dan Zwick says: sec
[10/30/2008 11:47:36 PM] Dan Zwick says: Is this an interpolating spline?
[10/30/2008 11:49:13 PM] yanhua Huang says: no sure, user can set default tolerane when create a constructed curve, when default tolerance is not zero, this cuve is not interpolating spline.
[10/30/2008 11:50:53 PM] Dan Zwick says: Well, the number of control points depends on the number of knots. If the spline doesn't interpolate all of the data then there will be fewer knots and control points than the number of points.
[10/30/2008 11:54:03 PM] Dan Zwick says: The number of knots depends on the thinning tolerance or thinning parameter. Once this is done, there will be m + 1 control points C[0],...,C[m], m + 5 knots t[0],...,t[m+4], of which only t[3],...,t[m+1] are distinct...
[10/30/2008 11:54:05 PM] Dan Zwick says: sec, telephone...
[10/30/2008 11:54:32 PM] Dan Zwick says: Ok, back
[10/30/2008 11:55:15 PM] Dan Zwick says: That means that t[0]=...=t[3] and t[m+1]=...=t[m+4] for an open spline.
[10/30/2008 11:56:01 PM] yanhua Huang says: m = number of points?
[10/30/2008 11:56:48 PM] Dan Zwick says: So coeffs would be m_Dim * (m + 1), but the maximum it can be is m_Dim * (m_numPoints + 1).
[10/31/2008 12:00:30 AM] yanhua Huang says: thanks. I changed my code as below.
double *coeffs = pdVector(m_Dim *(m_NumCPs + 1));
for(long i = 0; i < m_NumCPs; i++)
{
coeffs = m_CPs[0];
coeffs[m_NumCPs+1+i] = m_CPs[1];
coeffs[2*m_NumCPs+2+i] = m_CPs[2];
double *Pm = GETXYZ(inputs, i);
double *t0 = NULL;
curvdst(0, coeffs, m_NumCPs, m_pdKnots, m_Dim, Pm, Pm, m_pdKnots[0], t0, 0); // closed = 0, open-curve
}
[10/31/2008 12:01:01 AM] Dan Zwick says: Is it always a 3D curve?
[10/31/2008 12:01:24 AM] yanhua Huang says: 3D or 2D
[10/31/2008 12:01:51 AM] yanhua Huang says: If it is 2D....
[10/31/2008 12:02:48 AM] Dan Zwick says: double *coeffs = pdVector(m_Dim *(m_NumCPs + 1));
for(long i = 0; i < m_NumCPs; i++)
{
coeffs = m_CPs[0];
coeffs[m_NumCPs+1+i] = m_CPs[1];
if (m_nDim == 3)
coeffs[2*m_NumCPs+2+i] = m_CPs[2];
}

double *Pm = GETXYZ(inputs, i);
double *t0 = NULL;
curvdst(0, coeffs, m_NumCPs, m_pdKnots, m_Dim, Pm, Pm, m_pdKnots[0], t0, 0); // closed = 0, open-curve
[10/31/2008 12:04:25 AM] yanhua Huang says: Thanks very much.
[10/31/2008 12:04:28 AM] Dan Zwick says: Are the control points [m_Dim][m+1] or [m+1][m_Dim]?
[10/31/2008 12:05:14 AM] yanhua Huang says: checking
[10/31/2008 12:05:40 AM] Dan Zwick says: My guess is [m+1][m_Dim], in which case you would have to change the indices.
[10/31/2008 12:06:23 AM] yanhua Huang says: T:\V44B\CONSFEAT\CURVE.CPP(1783): m_CPs[0], // X Control Pnts
T:\V44B\CONSFEAT\CURVE.CPP(1784): m_CPs[1], // Y Control Pnts
T:\V44B\CONSFEAT\CURVE.CPP(1785): m_CPs[2], // Z Control Pnts
[10/31/2008 12:06:45 AM] yanhua Huang says: [m_Dim][m+1]
[10/31/2008 12:06:54 AM] Dan Zwick says: Ok
[10/31/2008 12:07:40 AM] Dan Zwick says: For what points do you want to use curvdst?
[10/31/2008 12:08:12 AM] yanhua Huang says: meas points projection onto curve
[10/31/2008 12:08:57 AM] Dan Zwick says: Ok
[10/31/2008 12:09:19 AM] Dan Zwick says: I think t0 is an initial guess for the spline parameter of the projected point.
[10/31/2008 12:09:57 AM] Dan Zwick says: So if you are going to find all of the closest points it would be a good idea to set it to the parameter found from the last point.
[10/31/2008 12:10:16 AM] Dan Zwick says: For the first point you can set it to 0.
[10/31/2008 12:17:39 AM] Dan Zwick says: Sorry, that's t_in.
[10/31/2008 12:18:44 AM] yanhua Huang says: I am going to find all of the closest points.
[10/31/2008 12:19:12 AM] yanhua Huang says: how to identify a point on curve?
[10/31/2008 12:19:23 AM] Dan Zwick says: Ok, so I would loop through all of the points, setting t_in to 0 for the first point and setting it to t0 for each subsequent point.
[10/31/2008 12:19:49 AM] Dan Zwick says: ?
[10/31/2008 12:20:03 AM] Dan Zwick says: Your input point is Pm, the output is the closest point P0.
[10/31/2008 12:20:24 AM] Dan Zwick says: ...and the parameter of the closest point t0.
[10/31/2008 12:21:04 AM] Dan Zwick says: t_in is an initial estimate of t0.
[10/31/2008 12:22:12 AM] yanhua Huang says: got it, I am tracint these variables in debug mode.
[10/31/2008 12:22:24 AM] Dan Zwick says: Ok
[10/31/2008 12:23:51 AM] Dan Zwick says: The return value from curvdst is the distance to the curve.
[10/31/2008 12:24:30 AM] Dan Zwick says: That is, the distance from the input point to the closest point on the spline curve.
[10/31/2008 12:26:21 AM] yanhua Huang says: vector at the closet point = closest point - input point?
[10/31/2008 12:27:26 AM] Dan Zwick says: Yes, or input point - closest point.
[10/31/2008 12:53:58 AM] yanhua Huang says: is m_KnotVec in machine CS?
[10/31/2008 12:54:56 AM] Dan Zwick says: Are those the points or the parameters of the knots?
[10/31/2008 12:55:08 AM] Dan Zwick says: If they are the points then they are a subset of the input points.
[10/31/2008 1:18:35 AM] yanhua Huang says: working.... Thanks again, bye, good day
[10/31/2008 1:19:04 AM] Dan Zwick says: Good! Bye
[11/3/2008 9:18:00 PM] yanhua Huang says: hi in?
[11/3/2008 11:42:36 PM] Dan Zwick says: Hi Yanhua, I'm in now.
[11/3/2008 11:43:02 PM] yanhua Huang added Donald Turcotte to this chat
[11/5/2008 10:39:01 PM] Click here to view remainder of this chat.
[11/5/2008 10:39:01 PM] yanhua Huang says: in?
[11/5/2008 10:39:19 PM] Dan Zwick says: Hi
[11/5/2008 10:39:51 PM] yanhua Huang says: I sent my questions by email.
[11/5/2008 10:40:01 PM] Dan Zwick says: k
[11/5/2008 10:41:21 PM] yanhua Huang added Donald Turcotte to this chat
[11/11/2008 11:48:37 PM] Click here to view remainder of this chat.
[11/11/2008 11:48:37 PM] yanhua Huang says: hi in?
[11/11/2008 11:48:56 PM] Dan Zwick says: Hi Yanhua
[11/11/2008 11:49:45 PM] yanhua Huang says: I start to working on per unit line profile when the considered feature is circle or ellipse.
[11/11/2008 11:50:17 PM] Dan Zwick says: Ok. There's a function that finds the closest point on an ellipse.
[11/11/2008 11:50:30 PM] yanhua Huang says: do you have a function to find meas point according to the given arc length.
[11/11/2008 11:51:35 PM] Dan Zwick says: Hmmm, could be. Arclength on an ellipse is a special function, an "elliptic function."
[11/11/2008 11:51:54 PM] Dan Zwick says: If I don't already have that I'm sure I could find one somewhere.
[11/11/2008 11:57:48 PM] Dan Zwick says: double _DSFITEXPORT CDSFitEllipse2D::closest_point_on_ellipse(double ra, double rb, double x0, double y0,
double alpha, double z0, double w0,
double *t0, double *xc, double *yc)
[12:19:07 AM] yanhua Huang says: /*-------------------------------------------------------------------*/
/* Find the closest point to a given point on an ellipse. */
/*-------------------------------------------------------------------*/

double _DSFITEXPORT CDSFitEllipse2D::closest_point_on_ellipse(double ra, double rb, double x0, double y0,
double alpha, double z0, double w0,
double *t0, double *xc, double *yc)
the comment is right?
[12:20:26 AM] yanhua Huang says: I want to calculate ellipse lenth between two meas points.
[12:27:30 AM] Dan Zwick says: Well, first you need to find the closest points on the ellipse and their parameters. There is no closed form expression for arc length on an ellipse, other than in terms of certain special functions. It might suffice to use Gaussian quadrature to approximate the arc length, though.
[12:31:24 AM] yanhua Huang says: approximate computation is OK
[12:31:59 AM] Dan Zwick says: Let me study this for a bit longer.
[12:33:44 AM] yanhua Huang says: By the way, recently I have a PR about the low efficiency when compute line profile deviation.
[12:34:12 AM] Dan Zwick says: For straight lines?
[12:34:39 AM] yanhua Huang says: when the considered feature is scan....
[12:34:50 AM] Dan Zwick says: Does that mean it takes too long?
[12:35:07 AM] yanhua Huang says: try to work on it tomorrow
[12:35:38 AM] yanhua Huang says: PR256106 - Profile dimension calculation very slow
[12:35:49 AM] yanhua Huang says: (chuckle)
[12:35:52 AM] Dan Zwick says: How many points are there in that scan?
[12:36:01 AM] Dan Zwick says: Some people expect miracles.
[12:36:19 AM] yanhua Huang says: >900
[12:36:45 AM] Dan Zwick says: Is this profile per unit length?
[12:37:11 AM] yanhua Huang says: no, old problem...
[12:37:48 AM] Dan Zwick says: 2D or 3D?
[12:37:53 AM] yanhua Huang says: Have not investigated the issue, just verify the issue.
[12:38:59 AM] yanhua Huang says: Let me trace the code firstly tomorrow. Just let you know....now
[12:39:17 AM] Dan Zwick says: Ok
[1:12:02 AM] Dan Zwick says: Take a look at ellipse_arc.cpp in MATHTOOL.
[1:13:58 AM] Dan Zwick says: This is used in HIT_HELP.CPP.
[1:16:58 AM] yanhua Huang says: which name is the function called?
[1:17:50 AM] Dan Zwick says: I suppose you need either ellipse_arc or ellipse_arc_inverse.
[1:19:48 AM] Dan Zwick says: It looks like I implemented all of that ellipse stuff, but I have completely forgotten it.
[1:20:08 AM] yanhua Huang says: (chuckle)perfect
[1:20:18 AM] Dan Zwick says: There are a bunch of other ellipse functions in hit_help.cpp.
[1:20:36 AM] Dan Zwick says: Which I apparently also wrote.
[1:21:31 AM] Dan Zwick says: In hit_help.cpp the task was to generate points equally spaced (according to arc length) on an ellipse.
[1:21:36 AM] yanhua Huang says: t_theta = ellipse_arc_inverse(t_theta, s_start + p * (s_end - s_start), M, N);
how to set t_theta?
[1:22:24 AM] Dan Zwick says: It's an initial guess.
[1:23:02 AM] Dan Zwick says: If you are starting at the beginning set it to 0. After that set it to whatever the previous theta was.
[1:23:17 AM] Dan Zwick says: That is, assuming you are going to do it for all points at once.
[1:24:43 AM] Dan Zwick says: Keep in mind that these ellipse functions assume that the ellipse is in standard position. That is, it has been rotated to the axes align with the x and y axes and the center is at the origin.
[1:24:58 AM] yanhua Huang says: Which feature should be created if I want to walk into ellipse_angle?
t:\V44B\HITS\HIT_HELP.CPP
[1:25:35 AM] Dan Zwick says: Also, it might make a difference where the larger semi axis is (along x or along y).
[1:27:04 AM] yanhua Huang says: max axis set to x?
[1:27:20 AM] Dan Zwick says: I'm not sure.
[1:29:03 AM] yanhua Huang says: thanks again, I will trace these code firstly tomorrow.
[1:29:31 AM] Dan Zwick says: Ok. M and N are the semi-axes, but I'm not sure which is which.
[1:30:37 AM] Dan Zwick says: theta = atan2(M * sin(t), N * cos(t))
[1:31:58 AM] Edited by Dan Zwick, 1:32:22 AM It looks like the equation of the ellipse here is
x = N cos(t), y = M sin(t), or (x/N)^2 + (y/M)^2 = 1.
[1:33:33 AM] Edited by Dan Zwick, 1:32:22 AM So N is along x, M is along y, but that doesn't necessarily mean that N > M.
[1:34:13 AM] yanhua Huang says: where is the comment?
[1:34:41 AM] yanhua Huang says: got it.
[1:35:09 AM] Dan Zwick says: Oh, there's also this:

// The following code is used by gen_ellipse_hits. It computes the polar angle of
// the point on the ellipse a proportion p of the way from the point on the perimeter
// corresponding to the polar angle start to the point on the perimeter corresponding
// to the polar angle end.
//
// NOTES.
// 1. The points on the ellipse are given in terms of the ellipse parameter t by
// (x,y) = (M cos(t), N sin(t)). The polar angle theta corresponding to (x,y) is
// arctan(y/x), which gives the conversion formula theta = arctan(N sin(t) / M cos(t)).
// 2. Arclength on an ellipse is expressed as an elliptic integral (of the second
// kind) with respect to the ellipse parameter t, which may be estimated to a high
// degree of accuracy. Once the arclength from start to end is computed, this integral
// has to be inverted in order to find the parameter t corresponding to the arclength
// of the desired point. This is done with Newton's Method.
[1:35:42 AM] Dan Zwick says: This is in hit_help.cpp.
[1:36:20 AM] Dan Zwick says: And that is definitely my English!
[1:38:09 AM] yanhua Huang says: (party) are there other notes?
[1:38:37 AM] Dan Zwick says: Just in the code.
[1:39:21 AM] Dan Zwick says: Funny I don't remember any of this. It was only a year ago. :S
[1:40:51 AM] yanhua Huang says: I try to look for the function using keyword = "ellipse" this afternoon,
[1:43:36 AM] yanhua Huang says: got >4000 matching lines results.
[1:44:59 AM] Dan Zwick says: Oh. I searched for elliptic integral.
[1:46:14 AM] yanhua Huang says: (F)I will go to |-)bed, good day,bye.
[1:46:36 AM] Dan Zwick says: Good night!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 19:10 , Processed in 0.056676 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表