-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathorthogonal.cpp
More file actions
43 lines (36 loc) · 818 Bytes
/
orthogonal.cpp
File metadata and controls
43 lines (36 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// C++ program to check if two
// circles are orthogonal or not
#include <bits/stdc++.h>
using namespace std;
// Function to Check if the given
// circles are orthogonal
bool orthogonality(int x1, int y1, int x2,
int y2, int r1, int r2)
{
// calculating the square
// of the distance between C1 and C2
int dsquare = (x1 - x2) * (x1 - x2)
+ (y1 - y2) * (y1 - y2);
// Check if the given
// circles are orthogonal
if (dsquare == r1 * r1 + r2 * r2)
return true;
else
return false;
}
// Driver code
int main()
{
int x1 = 4, y1 = 3;
int x2 = 0, y2 = 1;
int r1 = 2, r2 = 4;
bool f = orthogonality(x1, y1, x2,
y2, r1, r2);
if (f)
cout << "Given circles are"
<< " orthogonal.";
else
cout << "Given circles are"
<< " not orthogonal.";
return 0;
}