[wpimath] Mark all geometry classes as final (#8790)

In Java, these are likely to become value classes in the future.

Make C++ final for consistency.
This commit is contained in:
Gold856
2026-04-24 01:55:54 -04:00
committed by GitHub
parent 1586dcf385
commit d893d44e37
82 changed files with 84 additions and 82 deletions

View File

@@ -15,7 +15,7 @@ namespace wpi::math {
* A class representing a coordinate system axis within the NWU coordinate
* system.
*/
class WPILIB_DLLEXPORT CoordinateAxis {
class WPILIB_DLLEXPORT CoordinateAxis final {
public:
/**
* Constructs a coordinate system axis within the NWU coordinate system and

View File

@@ -19,7 +19,7 @@ namespace wpi::math {
* A helper class that converts Pose3d objects between different standard
* coordinate frames.
*/
class WPILIB_DLLEXPORT CoordinateSystem {
class WPILIB_DLLEXPORT CoordinateSystem final {
public:
/**
* Constructs a coordinate system with the given cardinal directions for each

View File

@@ -23,7 +23,7 @@ namespace wpi::math {
* Represents a 2d ellipse space containing translational, rotational, and
* scaling components.
*/
class WPILIB_DLLEXPORT Ellipse2d {
class WPILIB_DLLEXPORT Ellipse2d final {
public:
/**
* Constructs an ellipse around a center point and two semi-axes, a horizontal

View File

@@ -27,7 +27,7 @@ class Transform2d;
/**
* Represents a 2D pose containing translational and rotational elements.
*/
class WPILIB_DLLEXPORT Pose2d {
class WPILIB_DLLEXPORT Pose2d final {
public:
/**
* Constructs a pose at the origin facing toward the positive X axis.

View File

@@ -28,7 +28,7 @@ class Transform3d;
/**
* Represents a 3D pose containing translational and rotational elements.
*/
class WPILIB_DLLEXPORT Pose3d {
class WPILIB_DLLEXPORT Pose3d final {
public:
/**
* Constructs a pose at the origin facing toward the positive X axis.

View File

@@ -20,7 +20,7 @@ namespace wpi::math {
/**
* Represents a quaternion.
*/
class WPILIB_DLLEXPORT Quaternion {
class WPILIB_DLLEXPORT Quaternion final {
public:
/**
* Constructs a quaternion with a default angle of 0 degrees.

View File

@@ -21,7 +21,7 @@ namespace wpi::math {
* Represents a 2d rectangular space containing translational, rotational, and
* scaling components.
*/
class WPILIB_DLLEXPORT Rectangle2d {
class WPILIB_DLLEXPORT Rectangle2d final {
public:
/**
* Constructs a rectangle at the specified position with the specified width

View File

@@ -26,7 +26,7 @@ namespace wpi::math {
* A rotation in a 2D coordinate frame represented by a point on the unit circle
* (cosine and sine).
*/
class WPILIB_DLLEXPORT Rotation2d {
class WPILIB_DLLEXPORT Rotation2d final {
public:
/**
* Constructs a Rotation2d with a default angle of 0 degrees.

View File

@@ -69,7 +69,7 @@ namespace wpi::math {
* neat property is that applying a series of rotations extrinsically is the
* same as applying the same series in the opposite order intrinsically.
*/
class WPILIB_DLLEXPORT Rotation3d {
class WPILIB_DLLEXPORT Rotation3d final {
public:
/**
* Constructs a Rotation3d representing no rotation.

View File

@@ -18,7 +18,7 @@ struct Twist2d;
/**
* Represents a transformation for a Pose2d in the pose's frame.
*/
class WPILIB_DLLEXPORT Transform2d {
class WPILIB_DLLEXPORT Transform2d final {
public:
/**
* Constructs the transform that maps the initial pose to the final pose.

View File

@@ -20,7 +20,7 @@ struct Twist3d;
* applied before rotation. (The translation is applied in the pose's original
* frame, not the transformed frame.)
*/
class WPILIB_DLLEXPORT Transform3d {
class WPILIB_DLLEXPORT Transform3d final {
public:
/**
* Constructs the transform that maps the initial pose to the final pose.

View File

@@ -30,7 +30,7 @@ namespace wpi::math {
* When the robot is at the origin facing in the positive X direction, forward
* is positive X and left is positive Y.
*/
class WPILIB_DLLEXPORT Translation2d {
class WPILIB_DLLEXPORT Translation2d final {
public:
/**
* Constructs a Translation2d with X and Y components equal to zero.

View File

@@ -31,7 +31,7 @@ namespace wpi::math {
* robot is at the origin facing in the positive X direction, forward is
* positive X, left is positive Y, and up is positive Z.
*/
class WPILIB_DLLEXPORT Translation3d {
class WPILIB_DLLEXPORT Translation3d final {
public:
/**
* Constructs a Translation3d with X, Y, and Z components equal to zero.

View File

@@ -20,7 +20,7 @@ class Transform2d;
*
* A Twist can be used to represent a difference between two poses.
*/
struct WPILIB_DLLEXPORT Twist2d {
struct WPILIB_DLLEXPORT Twist2d final {
/**
* Linear "dx" component
*/

View File

@@ -20,7 +20,7 @@ class Transform3d;
*
* A Twist can be used to represent a difference between two poses.
*/
struct WPILIB_DLLEXPORT Twist3d {
struct WPILIB_DLLEXPORT Twist3d final {
/**
* Linear "dx" component
*/

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Ellipse2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Ellipse2d> final {
using MessageStruct = wpi_proto_ProtobufEllipse2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Ellipse2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Ellipse2d>;

View File

@@ -11,7 +11,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Pose2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Pose2d> final {
using MessageStruct = wpi_proto_ProtobufPose2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Pose2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Pose2d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Pose3d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Pose3d> final {
using MessageStruct = wpi_proto_ProtobufPose3d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Pose3d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Pose3d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Quaternion> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Quaternion> final {
using MessageStruct = wpi_proto_ProtobufQuaternion;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Quaternion>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Quaternion>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rectangle2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rectangle2d> final {
using MessageStruct = wpi_proto_ProtobufRectangle2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Rectangle2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Rectangle2d>;

View File

@@ -11,7 +11,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rotation2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rotation2d> final {
using MessageStruct = wpi_proto_ProtobufRotation2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Rotation2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Rotation2d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rotation3d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Rotation3d> final {
using MessageStruct = wpi_proto_ProtobufRotation3d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Rotation3d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Rotation3d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Transform2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Transform2d> final {
using MessageStruct = wpi_proto_ProtobufTransform2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Transform2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Transform2d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Transform3d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Transform3d> final {
using MessageStruct = wpi_proto_ProtobufTransform3d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Transform3d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Transform3d>;

View File

@@ -11,7 +11,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Translation2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Translation2d> final {
using MessageStruct = wpi_proto_ProtobufTranslation2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Translation2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Translation2d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Translation3d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Translation3d> final {
using MessageStruct = wpi_proto_ProtobufTranslation3d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Translation3d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Translation3d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Twist2d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Twist2d> final {
using MessageStruct = wpi_proto_ProtobufTwist2d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Twist2d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Twist2d>;

View File

@@ -10,7 +10,7 @@
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Twist3d> {
struct WPILIB_DLLEXPORT wpi::util::Protobuf<wpi::math::Twist3d> final {
using MessageStruct = wpi_proto_ProtobufTwist3d;
using InputStream = wpi::util::ProtoInputStream<wpi::math::Twist3d>;
using OutputStream = wpi::util::ProtoOutputStream<wpi::math::Twist3d>;

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Ellipse2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Ellipse2d> final {
static constexpr std::string_view GetTypeName() { return "Ellipse2d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Pose2d>() + 16;

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Pose2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Pose2d> final {
static constexpr std::string_view GetTypeName() { return "Pose2d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Translation2d>() +

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Pose3d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Pose3d> final {
static constexpr std::string_view GetTypeName() { return "Pose3d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Translation3d>() +

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Quaternion> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Quaternion> final {
static constexpr std::string_view GetTypeName() { return "Quaternion"; }
static constexpr size_t GetSize() { return 32; }
static constexpr std::string_view GetSchema() {

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rectangle2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rectangle2d> final {
static constexpr std::string_view GetTypeName() { return "Rectangle2d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Pose2d>() + 16;

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rotation2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rotation2d> final {
static constexpr std::string_view GetTypeName() { return "Rotation2d"; }
static constexpr size_t GetSize() { return 8; }
static constexpr std::string_view GetSchema() { return "double value"; }

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rotation3d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Rotation3d> final {
static constexpr std::string_view GetTypeName() { return "Rotation3d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Quaternion>();

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Transform2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Transform2d> final {
static constexpr std::string_view GetTypeName() { return "Transform2d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Translation2d>() +

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Transform3d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Transform3d> final {
static constexpr std::string_view GetTypeName() { return "Transform3d"; }
static constexpr size_t GetSize() {
return wpi::util::GetStructSize<wpi::math::Translation3d>() +

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Translation2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Translation2d> final {
static constexpr std::string_view GetTypeName() { return "Translation2d"; }
static constexpr size_t GetSize() { return 16; }
static constexpr std::string_view GetSchema() { return "double x;double y"; }

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Translation3d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Translation3d> final {
static constexpr std::string_view GetTypeName() { return "Translation3d"; }
static constexpr size_t GetSize() { return 24; }
static constexpr std::string_view GetSchema() {

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Twist2d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Twist2d> final {
static constexpr std::string_view GetTypeName() { return "Twist2d"; }
static constexpr size_t GetSize() { return 24; }
static constexpr std::string_view GetSchema() {

View File

@@ -9,7 +9,7 @@
#include "wpi/util/struct/Struct.hpp"
template <>
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Twist3d> {
struct WPILIB_DLLEXPORT wpi::util::Struct<wpi::math::Twist3d> final {
static constexpr std::string_view GetTypeName() { return "Twist3d"; }
static constexpr size_t GetSize() { return 48; }
static constexpr std::string_view GetSchema() {