INSTITUTE OF SPACE TECHNOLOGY
ISLAMABAD
ELECTRICAL ENGINEERING
DEPARTMENT
COMPUTER PROGRAMMING
FINAL PROJECT
EE-23
SUBMITTED BY :
MUHAMMAD ABUBAKAR (240401006)
MUSTAFA (EE-22)
SUBMITTED TO :
DR. ALI IRTAZA
DATE :
20 JUNE 2025
C++ Satellite Position Estimator -
Project Report
Introduction
This C++ program simulates how a basic GPS
(Global Positioning System) might estimate
the position of a user based on data received
from satellites. Using a simplified method
called weighted average trilateration, the
program uses the position and signal
distances of satellites to calculate the
approximate location.
Objective
To develop a simple and efficient C++
program that estimates a user's 2D location
using data from at least three satellites. Each
satellite provides its position and the
measured distance to the user. The program
outputs the estimated coordinates of the user.
Tools & Technologies
- Language: C++
- Compiler: Any standard C++ compiler (e.g.,
g++, Code::Blocks, Turbo C++)
- Platform: Console-based (no GUI)
- Memory Management: Dynamic allocation
using `new` and `delete`
Key Concepts Implemented
- Structures (`struct`): To group satellite
data (x, y, distance)
- Dynamic Memory Allocation: Using `new`
and `delete` for arrays
- Weighted Average: Simplified trilateration
to estimate location
- Input Validation: Minimum number of
satellites required is 3
- Loops and Conditionals: `for` loops, `if`
statements
- Basic Math and Geometry: For position
estimation
Program Features
- Accepts any number of satellites
(minimum 3)
- Dynamically stores satellite data
- Calculates weighted average of satellite
positions based on signal distance
- Provides an estimated 2D position of the
user
- Uses basic and readable C++ code
- Releases memory at the end using
`delete[]`
Program Flow
1. Input Phase:
- Prompt the user to enter the number of
satellites.
- If fewer than 3, display an error and exit.
- Allocate memory dynamically for satellite
data.
- Collect (x, y, distance) for each satellite.
2. Processing Phase:
- For each satellite, calculate weight as
`1/distance`.
- Multiply each x and y coordinate with its
weight.
- Sum up all weighted x and y values and
total weight.
3. Estimation Phase:
- Compute the final position using:
- Estimated X = sum(x_i * w_i) / sum(w_i)
- Estimated Y = sum(y_i * w_i) / sum(w_i)
4. Output Phase:
- Display the estimated position.
5. Cleanup:
- Release dynamically allocated memory.
Source Code
#include <iostream>
using namespace std;
struct Satellite {
double x, y, distance;
};
int main() {
int n;
cout << "Enter number of
satellites (min 3): ";
cin >> n;
if (n < 3) {
cout << "At least 3 satellites
required.\n";
return 1;
}
Satellite* sats = new
Satellite[n];
for (int i = 0; i < n; ++i) {
cout << "Satellite " << i + 1 <<
" (x y distance): ";
cin >> sats[i].x >> sats[i].y >>
sats[i].distance;
}
double sumX = 0, sumY = 0,
totalW = 0;
for (int i = 0; i < n; ++i) {
double w = 1.0 /
sats[i].distance;
sumX += sats[i].x * w;
sumY += sats[i].y * w;
totalW += w;
}
cout << "\nEstimated Position:
(" << sumX / totalW << ", " <<
sumY / totalW << ")\n";
delete[] sats;
return 0;
}
Sample Output
Enter number of satellites (min
3): 3
Satellite 1 (x y distance): 0 0 5
Satellite 2 (x y distance): 10 0 5
Satellite 3 (x y distance): 5 10 10
Estimated Position: (5, 2.5)
Conclusion
This project is a simple but effective
demonstration of how location estimation
using satellites can be simulated in C++.
While it doesn't use advanced trilateration or
error correction techniques used in real GPS
systems, it captures the core idea using a
weighted average approach. The program
emphasizes core C++ concepts like structs,
loops, and dynamic memory, making it a great
beginner-to-intermediate level project.