Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up OpenSim::PointForceDirection #3890

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ request related to the change, then we may provide the commit.

This is not a comprehensive list of changes but rather a hand-curated collection of the more notable ones. For a comprehensive history, see the [OpenSim Core GitHub repo](https://github.com/opensim-org/opensim-core).

Upcoming Release
================

- `PointForceDirection` no longer has a virtual destructor, is `final`, and its `scale` functionality
has been marked as `[[deprecated]]`

v4.6
====
- The performance of `getStateVariableValue`, `getStateVariableDerivativeValue`, and `getModelingOption` was improved in
Expand Down
94 changes: 49 additions & 45 deletions OpenSim/Simulation/Model/PointForceDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA *
* through the Warrior Web program. *
* *
* Copyright (c) 2005-2017 Stanford University and the Authors *
* Author(s): Ajay Seth *
* Copyright (c) 2005-2024 Stanford University and the Authors *
* Author(s): Ajay Seth, Adam Kewley *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain a *
Expand All @@ -23,70 +23,74 @@
* limitations under the License. *
* -------------------------------------------------------------------------- */

// INCLUDES
#include <OpenSim/Simulation/Model/PhysicalFrame.h>
#include <OpenSim/Simulation/osimSimulationDLL.h>

namespace OpenSim {

class Body;
class PhysicalFrame;
//=============================================================================
//=============================================================================
/** Convenience class for a generic representation of geometry of a complex
Force (or any other object) with multiple points of contact through
which forces are applied to bodies. This represents one such point and an
array of these objects defines a complete Force distribution (ie. path).

/**
* Convenience class for a generic representation of geometry of a complex
* Force (or any other object) with multiple points of contact through
* which forces are applied to bodies. This represents one such point and an
* array of these objects defines a complete Force distribution (ie. path).
*
* @author Ajay Seth
* @version 1.0
*/
class OSIMSIMULATION_API PointForceDirection final {
public:
PointForceDirection(
SimTK::Vec3 point,
const PhysicalFrame& frame,
SimTK::Vec3 direction) :

class OSIMSIMULATION_API PointForceDirection
{
_point(point), _frame(&frame), _direction(direction)
{}

//=============================================================================
// MEMBER VARIABLES
//=============================================================================
private:
/** Point of "contact" with a body, defined in the body frame */
SimTK::Vec3 _point;
/** The frame in which the point is defined */
const PhysicalFrame &_frame;
/** Direction of the force at the point, defined in ground */
SimTK::Vec3 _direction;
/** Optional parameter to scale the force that results from a scalar
(tension) multiplies the direction */
double _scale;
//=============================================================================
// METHODS
//=============================================================================
//--------------------------------------------------------------------------
// CONSTRUCTION
//--------------------------------------------------------------------------
public:
virtual ~PointForceDirection() {};
/** Default constructor takes the point, body, direction and scale
as arguments */
PointForceDirection(SimTK::Vec3 point, const PhysicalFrame &frame,
SimTK::Vec3 direction, double scale=1):
_point(point), _frame(frame), _direction(direction), _scale(scale)
[[deprecated("the 'scale' functionality should not be used in new code: OpenSim already assumes 'direction' is non-unit-length")]]
PointForceDirection(
SimTK::Vec3 point,
const PhysicalFrame& frame,
SimTK::Vec3 direction,
double scale) :

_point(point), _frame(&frame), _direction(direction), _scale(scale)
{}

/** get point of "contact" with on a body defined in the body frame */
SimTK::Vec3 point() {return _point; }
SimTK::Vec3 point() { return _point; }

/** get the body in which the point is defined */
const PhysicalFrame& frame() {return _frame; }
const PhysicalFrame& frame() { return *_frame; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to bring this up to date, I think the comment on L66 (and similar) should refer to PhysicalFrame rather than "body" since not all PhysicalFrames are Bodys.


/** get direction of the force at the point defined in ground */
SimTK::Vec3 direction() {return _direction; }
SimTK::Vec3 direction() { return _direction; }

/** get the scale factor on the force */
double scale() {return _scale; }
[[deprecated("this functionality should not be used in new code: OpenSim already assumes 'direction' is non-unit-length")]]
double scale() { return _scale; }

/** replace the current direction with the resultant with a new direction */
void addToDirection(SimTK::Vec3 newDirection) {_direction+=newDirection;}
void addToDirection(SimTK::Vec3 newDirection) { _direction += newDirection; }

private:
/** Point of "contact" with a body, defined in the body frame */
SimTK::Vec3 _point;

/** The frame in which the point is defined */
const PhysicalFrame* _frame;

/** Direction of the force at the point, defined in ground */
SimTK::Vec3 _direction;

/** Deprecated parameter to scale the force that results from a scalar
(tension) multiplies the direction */
double _scale = 1.0;
};

//=============================================================================
}; // END of class PointForceDirection
//=============================================================================
} // namespace

#endif // __PointForceDirection_h__
Loading