WPILibC++  unspecified
Vector2d.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 namespace frc {
11 
15 struct Vector2d {
16  Vector2d() = default;
17  Vector2d(double x, double y);
18 
19  void Rotate(double angle);
20  double Dot(const Vector2d& vec) const;
21  double Magnitude() const;
22  double ScalarProject(const Vector2d& vec) const;
23 
24  double x = 0.0;
25  double y = 0.0;
26 };
27 
28 } // namespace frc
double Magnitude() const
Returns magnitude of vector.
Definition: Vector2d.cpp:48
Definition: RobotController.cpp:14
double ScalarProject(const Vector2d &vec) const
Returns scalar projection of this vector onto argument.
Definition: Vector2d.cpp:55
void Rotate(double angle)
Rotate a vector in Cartesian space.
Definition: Vector2d.cpp:26
double Dot(const Vector2d &vec) const
Returns dot product of this vector with argument.
Definition: Vector2d.cpp:41
This is a 2D vector struct that supports basic vector operations.
Definition: Vector2d.h:15