luckYrat's library.

This documentation is automatically generated by competitive-verifier/competitive-verifier


:heavy_check_mark: cpp/geometry/point.hpp

Depends on

Required by

Verified with

Code

#pragma once
#include "./vec.hpp"

struct Point{
  long double x,y;

  Vec operator-(Point b){
    return {x-b.x, y-b.y};
  }
  Point operator+(long double a){
    return {x+a, y+a};
  }
  Point operator+(Vec v){
    return {x+v.x, y+v.y};
  }

  friend istream &operator>>(istream &is, Point &p){
    long double a,b;
    cin>>a>>b;
    p = Point({a,b});
    return (is);
  }

  friend ostream &operator<<(ostream &os, const Point &p){
    return os << p.x << " " << p.y;
  }

};
#line 2 "cpp/geometry/vec.hpp"

struct Vec{
  long double x,y;
  Vec operator*(long double a){
    return {x*a, y*a};
  }
  Vec operator/(long double a){
    return {x/a, y/a};
  }

  friend ostream &operator<<(ostream &os, const Vec &p){
    return os << p.x << " " << p.y;
  }
};

long double magnitude(Vec v){
  return sqrt(v.x*v.x+v.y*v.y);
}

Vec standardize(Vec v){
  return v/magnitude(v);
}
#line 3 "cpp/geometry/point.hpp"

struct Point{
  long double x,y;

  Vec operator-(Point b){
    return {x-b.x, y-b.y};
  }
  Point operator+(long double a){
    return {x+a, y+a};
  }
  Point operator+(Vec v){
    return {x+v.x, y+v.y};
  }

  friend istream &operator>>(istream &is, Point &p){
    long double a,b;
    cin>>a>>b;
    p = Point({a,b});
    return (is);
  }

  friend ostream &operator<<(ostream &os, const Point &p){
    return os << p.x << " " << p.y;
  }

};
Back to top page