SlideShare a Scribd company logo
1 of 2
Download to read offline
Here I have a function in my code that checks the separation of aircraft when called and returns
either no separation issues if the predicted paths of all other aircraft (stored in an expandable
array) does not intersect with the minimum distance circle around the current one when
comparing their relative position and velocity. it doesn't work though and I'm really confused as
to what is wrong. I can send the rest of the code through if required
void check_separation(ADSBPacket *plane, int planes_info)
{
int num = -1;
for(int i = 0; i < planes_info; i++)
{
if(plane[planes_info].id == plane[i].id)
{ num = i; break;
}
}
int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60); int new_time =
(plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60);
int time_change = new_time - original_time;
double distance = plane[num].speed * time_change / 1000; double angle = plane[num].heading *
M_PI / 180;
double east_change = distance * cos(angle);
double north_change = distance * sin(angle); plane[planes_info].north = plane[num].north +
north_change;
plane[planes_info].east = plane[num].east + east_change;
plane[planes_info].heading = plane[num].heading;
for(int i = 0; i < planes_info; i++)
{
int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60);
int new_time = (plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60);
int time_change = new_time - original_time;
double distance = plane[i].speed * time_change / 1000;
double angle = plane[i].heading * M_PI / 180;
double east_change = distance * cos(angle);
double north_change = distance * sin(angle);
plane[planes_info].north = plane[i].north + north_change;
plane[planes_info].east = plane[i].east + east_change;
plane[planes_info].heading = plane[num].heading;
double delta_p_north = plane[planes_info].north - plane[num].north;
double delta_p_east = plane[planes_info].east - plane[num].east;
double delta_v_north = (plane[planes_info].speed * sin(plane[i].heading)) - (plane[num].speed *
sin(plane[i].heading));
double delta_v_east = (plane[planes_info].speed * cos(plane[i].heading)) - (plane[num].speed *
cos(plane[i].heading));
double a = (delta_v_east * delta_v_east) + (delta_v_north * delta_v_north);
double b = 2 * ((delta_v_north * delta_p_north) + (delta_v_east * delta_p_east));
double separation = 100; double c = (delta_p_north * delta_p_north) + (delta_p_east +
delta_p_east) - (separation * separation);
if((b * b)- (4 * a * c) >= 0)
{
printf("Separation issuen"); break; }
}
printf("No separation issuesn");
}

More Related Content

Similar to Here I have a function in my code that checks the separation of airc.pdf

I am trying to implement timing on this program and cannot do it. Wh.pdf
I am trying to implement timing on this program and cannot do it. Wh.pdfI am trying to implement timing on this program and cannot do it. Wh.pdf
I am trying to implement timing on this program and cannot do it. Wh.pdf
allystraders
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
Neeraj Kaushik
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Mario Fusco
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)
NilayChavhan
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
ivylinvaydak64229
 

Similar to Here I have a function in my code that checks the separation of airc.pdf (20)

I am trying to implement timing on this program and cannot do it. Wh.pdf
I am trying to implement timing on this program and cannot do it. Wh.pdfI am trying to implement timing on this program and cannot do it. Wh.pdf
I am trying to implement timing on this program and cannot do it. Wh.pdf
 
Jamming attack in wireless network
Jamming attack in wireless networkJamming attack in wireless network
Jamming attack in wireless network
 
Lab 1 izz
Lab 1 izzLab 1 izz
Lab 1 izz
 
Naive application of Machine Learning to Software Development
Naive application of Machine Learning to Software DevelopmentNaive application of Machine Learning to Software Development
Naive application of Machine Learning to Software Development
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 
Javascript
JavascriptJavascript
Javascript
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Rkf
RkfRkf
Rkf
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Functional C++
Functional C++Functional C++
Functional C++
 
Aodv routing protocol code in ns2
Aodv routing protocol code in ns2Aodv routing protocol code in ns2
Aodv routing protocol code in ns2
 
Standing the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider PatternStanding the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider Pattern
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
Include stdio. wps office (1)
Include  stdio. wps office (1)Include  stdio. wps office (1)
Include stdio. wps office (1)
 
c++ #include -iostream- using namespace std- void InsertionSort(int nu.pdf
c++ #include -iostream- using namespace std- void InsertionSort(int nu.pdfc++ #include -iostream- using namespace std- void InsertionSort(int nu.pdf
c++ #include -iostream- using namespace std- void InsertionSort(int nu.pdf
 
week-3x
week-3xweek-3x
week-3x
 
In this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdfIn this assignment you will practice creating classes and enumeratio.pdf
In this assignment you will practice creating classes and enumeratio.pdf
 
Computer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxesComputer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxes
 
Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdf
 

More from Conint29

Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdf
Conint29
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
Conint29
 
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover  Back in July 30th 1971, the c.pdfDomain Description for the Lunar Rover  Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
Conint29
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
Conint29
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdf
Conint29
 
How do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdfHow do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdf
Conint29
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
Conint29
 
Encapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdfEncapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdf
Conint29
 
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdfHello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
Conint29
 

More from Conint29 (13)

Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdf
 
Fix my codeCode.pdf
Fix my codeCode.pdfFix my codeCode.pdf
Fix my codeCode.pdf
 
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover  Back in July 30th 1971, the c.pdfDomain Description for the Lunar Rover  Back in July 30th 1971, the c.pdf
Domain Description for the Lunar Rover Back in July 30th 1971, the c.pdf
 
Design a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdfDesign a PIC based wearable device that keeps a tract of the activit.pdf
Design a PIC based wearable device that keeps a tract of the activit.pdf
 
Describe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdfDescribe any five (5) advantages of computer networkingList any (5) ex.pdf
Describe any five (5) advantages of computer networkingList any (5) ex.pdf
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdf
 
how to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdfhow to Create a PDF holding all of your database data from Module 8..pdf
how to Create a PDF holding all of your database data from Module 8..pdf
 
How do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdfHow do I declare the following constructors in my .h file Below.pdf
How do I declare the following constructors in my .h file Below.pdf
 
File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
Exchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdfExchange Rate Determination Theory OvershootingExchange rate over.pdf
Exchange Rate Determination Theory OvershootingExchange rate over.pdf
 
Encapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdfEncapsulating method details in a class [ Choose ] instance vari.pdf
Encapsulating method details in a class [ Choose ] instance vari.pdf
 
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdfHello. I need help with my assignment. Translate the ER Diagram for .pdf
Hello. I need help with my assignment. Translate the ER Diagram for .pdf
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 

Here I have a function in my code that checks the separation of airc.pdf

  • 1. Here I have a function in my code that checks the separation of aircraft when called and returns either no separation issues if the predicted paths of all other aircraft (stored in an expandable array) does not intersect with the minimum distance circle around the current one when comparing their relative position and velocity. it doesn't work though and I'm really confused as to what is wrong. I can send the rest of the code through if required void check_separation(ADSBPacket *plane, int planes_info) { int num = -1; for(int i = 0; i < planes_info; i++) { if(plane[planes_info].id == plane[i].id) { num = i; break; } } int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60); int new_time = (plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60); int time_change = new_time - original_time; double distance = plane[num].speed * time_change / 1000; double angle = plane[num].heading * M_PI / 180; double east_change = distance * cos(angle); double north_change = distance * sin(angle); plane[planes_info].north = plane[num].north + north_change; plane[planes_info].east = plane[num].east + east_change; plane[planes_info].heading = plane[num].heading; for(int i = 0; i < planes_info; i++) { int original_time = (plane[num].hours * 3600) + (plane[num].minutes * 60); int new_time = (plane[planes_info].hours * 3600) + (plane[planes_info].minutes * 60); int time_change = new_time - original_time; double distance = plane[i].speed * time_change / 1000; double angle = plane[i].heading * M_PI / 180; double east_change = distance * cos(angle); double north_change = distance * sin(angle); plane[planes_info].north = plane[i].north + north_change; plane[planes_info].east = plane[i].east + east_change;
  • 2. plane[planes_info].heading = plane[num].heading; double delta_p_north = plane[planes_info].north - plane[num].north; double delta_p_east = plane[planes_info].east - plane[num].east; double delta_v_north = (plane[planes_info].speed * sin(plane[i].heading)) - (plane[num].speed * sin(plane[i].heading)); double delta_v_east = (plane[planes_info].speed * cos(plane[i].heading)) - (plane[num].speed * cos(plane[i].heading)); double a = (delta_v_east * delta_v_east) + (delta_v_north * delta_v_north); double b = 2 * ((delta_v_north * delta_p_north) + (delta_v_east * delta_p_east)); double separation = 100; double c = (delta_p_north * delta_p_north) + (delta_p_east + delta_p_east) - (separation * separation); if((b * b)- (4 * a * c) >= 0) { printf("Separation issuen"); break; } } printf("No separation issuesn"); }