Skip to main content
1-Visitor
November 12, 2015
Question

Solving for Intersections within a For Loop.

  • November 12, 2015
  • 1 reply
  • 4362 views

Hi MathCAD Community,

To start I will try and give some background to the problem:

I have imported some data points that represent two edge curves of a surface in Creo. Using Matricies I can rotate these data points by a given angle made up of Yaw and Pitch. I then project these rotated data points to the zero plane using a projection Matrix. Next I fit a function through the two sets of transformed data and using integrals I calculate the area between these curves.

Now that I have worked out how to do this by specifying the rotation angle I want to iterate through 180 degrees of rotation in Yaw and Pitch to find the orientation that provides the smallest area between the curves.

My problem is when I go to find the potential intersection points of the two curves (for defining integral limits) I use a solve block, which cannot be implemented within a for loop for iterating through angles...

If anyone could help me find a solution to this ASAP it would be greatly appreciated. I have attached my methodology for completing this without iterating through a For loop.

Dion

1 reply

23-Emerald V
November 12, 2015

Andrew Bissett wrote:

I have imported some data points that represent two edge curves of a surface in Creo. Using Matricies I can rotate these data points by a given angle made up of Yaw and Pitch. I then project these rotated data points to the zero plane using a projection Matrix. Next I fit a function through the two sets of transformed data and using integrals I calculate the area between these curves.

Now that I have worked out how to do this by specifying the rotation angle I want to iterate through 180 degrees of rotation in Yaw and Pitch to find the orientation that provides the smallest area between the curves.

My problem is when I go to find the potential intersection points of the two curves (for defining integral limits) I use a solve block, which cannot be implemented within a for loop for iterating through angles...

The general approach to this kind of problem is to make the solve block a function of the variables you want to vary.  Please see the attached worksheet.  Unfortunately, it means propagating those function arguments back through the worksheet.

Sorry about the layout of your worksheet ...

Stuart

abissett1-VisitorAuthor
1-Visitor
November 12, 2015

Sorry I'm not sure I follow completely. I understand what you have done but then how do I iterate through the whole process if the solve block still cant be used within a for loop?

19-Tanzanite
November 12, 2015

I can't read Stuart's worksheet because it's in Prime 3.1 format, but at the end of the solve block there should be a function, something like

f(yaw, pitch):=Find(limits)

You can use that function anywhere later in the worksheet, including in a program. Or, in another solve block, which is almost certainly a better way to minimize the area than iterating to a solution in a program.