## Introduction

In the first part of this lab you went through the building blocks that will allow you to set up the models in a basic network in a 2D planar coordinate system:

While these are basic, even these simple linearized models can come together to make for a pretty powerful tool that can help you understand the design and analysis of networks.

And that’s what we’re setting the stage for with this lab. You’re going to begin putting all these pieces together.

## Situation

Imagine that you want to know the coordinates of two new previously un-surveyed points, and , in a network where the coordinates of three points, , , and are already known.

Further imagine that you plan to measure the distances, , and angles, , shown in the figure below.

And imagine that you are given the following:

The coordinates of the known points:

The measurements:

• of the distance between points and : , (measured twice)
• of the distance between points and :
• of the distance between points and :
• of the distance between points and : ,  (measured twice)
• of the distance between points and
• of the angle measured at point between points and :  (measured twice)
• of the angle measured at point between points and :  (measured twice)
• of the angle measured at point between points and :

The approximate coordinates of the unknown points:

## Step 1: Pre-analysis

In your report for Part 2 of this lab I want you to include a pre-analysis. The pre-analysis should contain the following:

a) A summary of the situation including the sketch

b) A quick accounting for what are the values , , and for the whole thing

c) An explicit statement of what are the vectors , , , and in terms of the variables they represent, and what sizes they are (even though their sizes should be clear by looking at what’s in the matrices)

d) The corresponding nonlinear functional model, as a vector function, which means a set of equations like this:

e) An expression for the design matrix, , in terms of the partial derivatives needed to derive it for the case in the sketch. Include an indication of what size it is (although, again, this should be clear from looking at it).

f) An expression for the full matrix. The linearized models you developed in Part 1 of this lab should make pretty short work of this. That’s why you did all that work, so don’t hesitate to use it here.

g) An expression for the misclosure vector, , including an indication of its size too.

h) Anything else you think is relevant to developing the full linearized model in the form:

Notes:

• For the and matrices, you don’t need to calculate the values of each element in the matrices in this pre-analysis. Rather, you’re just clearly articulating the calculations that need to be made – so you can make them in the steps that follow. Think of the above as algorithm guidelines or requirements.
• As you’ll see below, I’d like a single report for Part 2 of this lab. It can be hand written or done digitally, but should be scanned to a PDF and saved to the folder you created for Lab 2. This pre-analysis should be the first section of that report.

## Step 2: Set up a project for a new console-based application

Like you did in Parts 1 and 3 of Lab 1, I want you to create a Windows-based console application in C++ using Microsoft Visual Studio, and using the Eigen matrix.

When doing this, be sure to:

• give your application an appropriate name, e.g. YourName-Lab2Part2
• include and use the Eigen template library in your project – I want you to use / get used to this now because it’s going to be so important to us in later labs
• properly document and organize your code
• create an executable that can be run on any Windows computer (although this time I’m not going to ask you to submit this – only to have it on hand in case we ask for it)

## Step 3: Write a library for setting up the linearized models from Part 1

As a first step in writing your own C++ geomatics networks library, I’d like you to create the functions required to implement the linearized model building blocks from Part 1 of this lab that are needed for the situation provided here.

Think of this as creating an include file that will allow you to efficiently fill the  matrix and vector for a given set of desired parameters, approximate values, and measurements.

Keep in mind as you’re doing this that:

• The next step (below) is to implement some code that calls these functions so you can calculate the required elements of the combined model for the situation given above.
• You won’t be solving for the unknown coordinates at all in this lab; only computing and . We’ll be dealing with errors and adjustments soon enough. My goal for this lab is for you to demonstrate a strong enough understanding of the functional modeling and linearization that I know you can set up basic networks in future labs too.
• Your program needs to be able to read the information contained under the heading “Situation” above from a file (of your own design based on the provided information).
• In future labs you won’t always be given exactly the same configuration of measurements and known coordinates, so the less you hard code things, the easier life might be for you in the future:
• There are various levels of automation and logic you could implement here, e.g. the format of your input file could use a logic and tags that specify things like: whether a line of the input file contains a measurement, a known coordinate, or an approximate coordinate; whether a measurement is of one type or another; whether a measured distance is between two unknown points or from one known point to an unknown point, etc … But this isn’t required – good code and an efficient input file format can achieve the same output that works perfectly well for this lab.

## Step 4: Calculate and output the A matrix and w vector

Next, you need to add code so that your application will:

• read the provided input from your own input file
• call the functions required to calculate and populate the values in the  matrix and vector
• output those to a new file containing:
• the vector or equivalent, just so readers of the output know the order of the unknowns you were working with and the units of each
• the computed matrix
• the computed vector, including some way of indicating to the reader the units of each row

## Step 5: Reflect on coding this kind of thing

In Part 1 of of this lab I asked you to develop some coding guidance for yourself. Go back and read it. Now I want you to tell me what guidance you’d give yourself in hindsight. Articulate this under the heading “Guidance I’d give my past self now on coding this”. As you will see from the assessment rubric, what I’m interested in here is that you can articulate:

• what’s required for coding the linearized models for a situation like the one provided to you
• what you learned by doing it that you didn’t know before, or what you confirmed about what you had predicted
• what you would do differently next time or if you had more time

## Step 6: Submit your code, and input and output files

When you’ve completely finished your application you need to submit it.

To do this, submit following according to the directions provided:

1. Your lab report, including:
• an introduction and preamble as required by the template
• your “Pre-analysis” section
• a section referring the reader to the code found in the appendices (see below)
• a section referring to the reader to the input and output files in the appendices (see below)
• a conclusion including your “Guidance I’d give my past self now on coding this”
• an appendix containing the input file you created
• a second appendix containing the output file created by your application
2. Listing of your code in the appendices