Using SolidWorks to Validate MATLAB Ray Simulation

Another use for geometric constraints and 3D sketches

Dr. Jody Muelaner, PhD CEng MIMechE

I recently wrote about some of the less well-known uses for sketches in parametric CAD software such as SolidWorks. The geometric constraint solvers that the sketch function is based on does some really clever optimization to solve very complex geometry problems in a highly intuitive graphical way. This functionality is included so that model dimensions can be easily changed and part geometry then automatically updated, preserving design intent. However, the geometry solving capability can be repurposed in many ways to create extremely powerful and intuitive models and optimizations. My previous article looked at how geometric constraints can be used to optimize linkage lengths and pivot positions to synthesize mechanisms that produce specified types of motion. In this article, I detail a case study where 3D sketches in SolidWorks were used to validate a complete ray path simulation being used to design an interferometer in MATLAB.

The Interferometer Design
The simulation was for a new laser measurement technique that would allow highly accurate and dynamic measurements between steel spheres. Steel spheres can be manufactured with a very accurately defined radius, allowing measurements from multiple directions to reference a common point at the center of the sphere. It would therefore be possible to measure multiple 3D coordinates with very high accuracy and full traceability to fundamental length standards. The novel interferometer which allows these measurements has been designed by researchers at the University of Oxford, University of Bath and the National Physical Laboratory (NPL).

The technique, known as Absolute Multilateration between Spheres (AMS), could one day allow the measurement of coordinates to within a few micrometers, over distances of tens of meters and with no environmental controls. Because the laser path is contained in a tube, environmental parameters can be controlled and measured for the beam path without controlling the entire environment. This could enable the next generation of aerospace structures to achieve natural laminar flow and part-to-part interchangeability.

Figure 1: Proposed applications for AMS, a fully traceable CMM and a highly accurate snake arm robot.

The diagram below shows the interferometer arrangement which allows an absolute distance measurement between steel spheres. It uses a fiber channeled laser source which can be shared between many individual distance measurements. The laser passes through a number of wave plates, changing its polarization plane and therefore allowing a polarization-dependent beam splitter to either reflect or pass the beam, depending on where it is in its path. The measurement beam, therefore, goes from the splitter to a collimating lens A, it then reflects off the beam splitter at B, reflects off the first sphere C, passes through the beam splitter, reflects off the second sphere D, reflects off the beam splitter at E and finally hits the detector at F. At the same time, a reference beam goes straight from A to F.

Figure 2: Interferometer arrangement for AMS.

Due to the convex nature of the spheres, the laser beam diverges when it is reflected, fanning out the rays into a cone shape. This means that only a small fraction of the measurement beam will reach the detector.

The MATLAB Simulation
A MATLAB simulation was developed which included a mathematical function for the path of a single ray ABCDEF. This function used vector geometry and had variables to represent the position of the ray in the beam at A and for the alignments of the components in the system. A numerical integration was then carried out which simulated a number of discrete rays within the beam to determine the laser power at the detector, the error of distance measurement and the ability to clearly resolve fringes.

With alignment errors, the path ABCDEF becomes A’B’C’D’E’F’. A ray on the reference path travels from point Ar to interfere with the measurement path ray at point F’. The coordinate system was centered at point B with the x-axis on path BA and the y-axis on path BC.

Figure 3: Beam Path Model.

Vector geometry can be used to find each of the points in the path in turn. For example, the direction of vector A’B’ is given by applying rotation matrices to the nominal direction vector:

The intersection of this vector with the plane of the beam splitter gives the position of B and the direction of B’C’ can be found by reflecting A’B’ about a vector normal to the beam splitter (Nx):

The intersection of the first sphere with vector B’C’ gives two possible positions for C. The one with the minimum y-coordinate is the correct one. The direction of C’D’ is then found by reflecting B’C’ about the surface normal to the sphere at point C’. The surface normal has the direction from the center of the sphere to the point C’. A similar process is carried out to model the rest of the ray path.

Because of the highly divergent nature of the beam, it was necessary to only simulate the very small part which would actually reach the detector. Simulating the entire beam with sufficient resolution to give meaningful results at the detector would have taken many years of computational solve time. However, due to alignment errors, it was not possible to determine which part of the beam would reach the detector without simulating the ray path. Therefore, an initial search had to be carried out to find the edges of the detector. These capabilities are not available in standard ray tracing software and therefore a bespoke MATLAB simulation was required.

Validating the Model in SolidWorks
A vector geometry model for a ray path with nominal geometry was relatively straight forward. However, when the alignment errors of each component were also included the model became somewhat complex and very difficult to directly verify. SolidWorks was used to validate the ray path model. A geometric constraint-based sketch provided a really useful and intuitive way to do this.

The first stage in creating the SolidWorks validation model was to create geometric elements for the spheres, beam splitter, laser source and detector. The spheres were modeled as solids, the beam splitter and detector were modeled as reference planes.

Figure 4: Fixed geometry elements in SolidWorks model.

The next stage was to model the actual ray path. Each straight line section of the ray path was modeled using a 3D sketch containing a line to represent the path. The surface normal for each surface of reflection was also included in the sketch as another straight line.

The first straight-line section of the ray path is AB. It originates from and in the direction of the laser source. Dimensions were included to represent the alignment errors. The endpoint of this line is set to be coincident with the beam splitter plane to find the position of point B.

Figure 5: Model of first straight-line section of ray path, AB.

The reflection of AB on the beam splitter was then modeled by finding the surface normal direction and reflecting on this vector. Within SolidWorks, the surface normal vector was modeled as an axis which is coincident with the endpoint of line AB and which is perpendicular to the plane of the beam splitter. Next, a reference plane was created for the plane of reflection, this is coincident with both the surface normal vector and the other endpoint of the line AB, at point A. Sketching on this plane, the direction vector for BC is a line that is symmetrical with the line AB about a centerline along the surface normal axis.

Figure 6: Constructing a surface normal vector and reflection plane to find the direction of BC.

Once the direction vector was established with a 2D sketch on the reflection plane, a 3D sketch was then used to find the actual path BC, ending at point C on the surface of the first sphere. The 3D sketch contains a single line with one endpoint coincident with B and collinear with the direction vector just created. The final unconstrained endpoint of the 3D sketch is coincident with the surface of the first sphere, determining the point of intersection between the ray and the sphere.

Figure 7: Determining the point of intersection between the ray and the sphere using a 3D sketch.

In order to reflect the beam off the surface of the sphere it is first necessary to find the surface normal at the point of reflection. There are two ways of achieving this, both using a 3D sketch containing a single line. One end of the line must be coincident with point C, the endpoint of BC on the surface of the sphere. It can then be set to be normal to the surface of the sphere, at this point, in one of two ways. Its other endpoint could be constrained to the center of the sphere, or alternatively the line could be constrained to be perpendicular to the surface of the sphere.

The reflection was then simulated as for the previous reflection. The plane of reflection was fully defined as coincident with the surface normal vector and the point at the other end of the incoming ray, B. The direction of CD was then found using a 2D sketch on the reflection plane, with a line that is symmetric to the incoming ray, about a centerline on the surface normal vector. Finally, a 3D sketch containing a single line was used to find the actual path CD with the point D coincident with the surface of the second sphere.

The process was repeated for the remaining sections of the ray path. In general, the process has four steps:

  1. Create a surface normal vector on the reflection surface, using a 3D sketch containing a single line.
  2. Create a reflection plane which is coincident with the surface normal vector and a point at the other end of the incoming ray.
  3. Create a direction vector for the outgoing ray, using a 2D sketch on the reflection plane with a centerline on the surface normal vector and a line, which is symmetrical to the incoming ray about the surface normal vector.
  4. Find the point of intersection for the ray path, using a 3D sketch which is coincident with the direction vector and has an endpoint coincident with the geometry representing the surface of reflection.

The geometric constraint-based sketches in parametric CAD programs such as SolidWorks can be adapted for use in many ways. This tool is a powerful and intuitive way to solve many engineering problems, which often have nothing to do with modeling part geometry.