Tutorial: Using Programming and Plot Manipulation to Triangulate a 2-D Point

Using Programming and Plot Manipulation to Triangulate a 2-D Point

Problem Background

This tutorial will demonstrate how to locate a point on an XY plane when given information about two or more points on the same plane. As a start, you will focus solely on determining the location of this point when given two reference points, but this problem has the potential to be expanded to incorporate more reference points.

Referring to Figure 1 on the right, you will notice that the two known points are labeled as ‘Reference Points’ and the point you will be finding is labeled as ‘Unknown Location’. It is important to note that both reference points are situated on the X-Axis, equidistant from the origin, and the distance between them is 2m. Theta (θ) is also labeled on this diagram as the angle measure between the segments connecting the unknown location with each reference point. A circle (Circle R) can be constructed whose circumference includes all three points, and whose radius and center are dependent on the magnitude of θ. This circle is actually a representation of all of the possible points on the XY plane that have the same measured θ. (Ref. Fig. 1)

Circle Variables:

  • 2m = (Distance between two reference points)
  • θ = (Angle measure between the segments connecting the unknown location to each reference point)
  • Radius = m•csc(θ)
  • Center = [0 m•cot(θ)]

Building the Circle Function

In Mathcad, you will construct a parametric equation for the x and y values of Circle R as a function of t and θ. To start, you will need to assign definitions for m, the radius (Rradius) and the center (Rcenter). You should define 1 as the value of m for the purpose of this exercise, but it can be reassigned to any positive number greater than zero. The definitions for the circle center and radius are given above (Ref. “Figure 1 - Circle Variables”). Note that the circle center should be defined as a transposed matrix, following the form: [ x y ]T.

Next, you will need to define the circle as the function R (t,θ) using the previous definitions for the circle radius and center. This function will also contain a transposed matrix. This matrix will be used to isolate the x-values and y-values of each point on the circle respectively by multiplying the radius by a cosine or sine value based on t. (Ref. Fig. 2)

Lastly, you will need to define t and θ as range variables. Variable t will begin at 0, end at 1, with a step size of 0.001. Variable θ will begin at 40 deg, end at 160 deg, with a step size of 10 deg. After doing this, you will be prepared to plot circles for multiple values of θ. (Ref. Fig. 3)

Writing the Program to Construct Matrices with X and Y Plot Values

In order to plot a circle for all values of θ on the same XY plane, you will need to write a program that will augment all of the matrices for either the x-values or the y-values per θ. This program will be the definition of the function Curves (F, dimNumber). Later on, variable F will be assigned to R from the circle function, and variable dimNumber will be assigned to 0 or 1. The dimNumber variable is the column index number of the augmented matrix in your previously defined circle function; column 0 is assigned to all x-values and column 1 is assigned to all y-values. At this point, please make sure the Matrix and Vector Index Origin is set to 0 on the Calculation tab.

The program you write will, for all values of t per θ, take the solution of function F and place it in a column with all solutions having the same θ, and a row with all solutions having the same t. Both the rows and columns will be in ascending order of magnitude for t and θ. (Ref. Fig. 4)

The last step before plotting is assigning the x and y matrices to their own variables. You will make xs the variable for the matrix formed with all x-values, and ys the variable for the matrix formed with all y-values of the function R. (Ref. Fig. 5)

Using a Waterfall Trace to Graph the Data

Inserting a waterfall trace takes two steps. First, you will need to insert a new plot under Traces in the Plot tab. Second, you must click on the Change Type button in the Traces section, and select Waterfall Trace. The Waterfall Trace will allow you to plot multiple data sets at once; in this case you will be plotting all columns of your xs and ys matrices simultaneously. Next, enter xs and ys respectively for the x and y-axes, and Mathcad will return a trace of thirteen circles, each with a different θ. (Ref. Fig. 6)

If you would like to restrict the viewed domain and range of the plot to D:{x| –m<x<m} and R:{y| 0<y}, you may alter the minimums and maximums of each axis to the necessary dimensions. (Ref. Fig. 7)

Possibilities to Expand Upon

As previously mentioned, you may expand this problem to have three or more reference points. By doing this, you will be able to triangulate a location at the intersection of two circles from different reference points. For your own interest, Figures 8 and 9 are example plots with three and six reference points. (Ref. Fig. 8 &9)

Learn more with other tutorials...

Regressing Data
  • Regressing Data

  • |
  • |
  • Intermediate Level
  • |
  • In this tutorial, you learn how to import and regress data using linear and polynomial regression.
Identify Operands For an Operator
  • Identify Operands For an Operator

  • |
  • |
  • Introductory Level
  • |
  • Learn how to identify the operands for an operator and replace an operator in a mathematical expression.
Creating a Basic X-Y Plot
  • Creating a Basic X-Y Plot

  • |
  • |
  • Introductory Level
  • |
  • In this tutorial you learn how to create a basic X-Y plot using Mathcad
Our tutorials are moving... Continue learning here!

A new home for PTC tutorials

Our free tutorials have a new home - and they are no longer alone. We have created the new PTC Learning Connector Portal to provide a one-stop shop for learning and support for PTC software. Access free tutorials, support content and eLearning via one single site.
Visit now   
Replay video? Resume video