Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define ld long double
- #define inf 9e18
- #define v vector
- #define min(a, b) (a < b ? a : b)
- #define max(a, b) (a > b ? a : b)
- struct Point {
- int x, y;
- };
- struct Vector {
- Point b, e;
- };
- ld distance(Point a, Point b) {
- return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
- }
- int sq_distance(Point a, Point b) {
- return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
- }
- int cross_product(Vector a, Vector b) {
- return (a.e.x - a.b.x)*(b.e.y - b.b.y) - (b.e.x - b.b.x)*(a.e.y - a.b.y);
- }
- int scalar_vector_multiply(Vector a, Vector b) {
- return (a.e.x - a.b.x)*(b.e.x - b.b.x) + (b.e.y - b.b.y)*(a.e.y - a.b.y);
- }
- signed main(signed argc, char* argv[]) {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- // cout.setf(ios::fixed);
- // cout.precision(6);
- // freopen("input.txt", "r", stdin);
- // freopen("output.txt", "w", stdout);
- Vector a;
- cin >> a.b.x >> a.b.y >> a.e.x >> a.e.y;
- Point c;
- cin >> c.x >> c.y;
- Vector b;
- b.b = a.b;
- b.e = c;
- ld len_a = distance(a.b, a.e);
- ld len_b = distance(b.b, b.e);
- int cp = cross_product(a, b);
- int svm = scalar_vector_multiply(a, b);
- if (cp == 0) {
- cout << "on line";
- } else if (cp > 0) {
- cout << "left line";
- } else {
- cout << "right line";
- }
- ld sin_a = cp / (len_a * len_b);
- ld cos_a = svm / (len_a * len_b);
- cout << "\nsin = " << sin_a;
- cout << "\ncos = " << cos_a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement