Comments (4)
Wikipedia also mentions this in its Slerp entry.
My thought would be that Simbody's Quaternion class should have a q=q1.slerp(f, q2)
function that returns a quaternion q some fraction f of the shortest way between q1 and q2. That seems better to me than exposing the non-canonical quaternion.
from simbody.
Thanks for the Wikipedia link. I should have found that!
Blender has a slerp()
method just like the one you propose: mathutils.Quaternion.slerp(q2, f)
. Blender calls that method internally when it interpolates quaternions. There's an important difference though. Blender's slerp()
does not pick the "shortest way between q1 and q2", which is what I was stymied by. It sometimes generates quaternions that lie on the long arc between q1 and q2. I therefore took things into my own hands and altered the quaternions I handed to Blender. Hence the origin of the static method that appears in my previous comment.
Even if SimTK::Quaternion_::slerp(f, q2)
were available to me, it wouldn't remove the need to call the static method I wrote (or one like it) however. I don't have a way (that I'm aware of) of asking Blender to use SimTK::Quaternion::slerp(f, q2)
for the interpolations that Blender performs internally.
Your proposed slerp() sent me back to dig more into Blender's API, thinking Blender MUST have an approach for ensuring short-arc interpolations. Having missed it the first few times I looked through the API again, and I think I've identified the approach. The short arc decision is handled in a method intended to be called prior to the slerp() method. The call is q2.make_compatible(q1)
, which changes q2 to the form (canonical or non-canonical) that makes the angle between q1 and q2 less than 180°, which is what my static method does.
Since it is so much faster to do in C++, it would still be nice to have the SimTK Slerp method. However, I would want two methods:
/// Return a quaternion, expressed in canonical form, that is some fraction f along the shortest
/// path between this quaternion and a specified quaternion q2.
Quaternion_ Quaternion_::slerp(const RealP& f, const Quaternion_& q2) const {
// Ensure interpolation with q2 will result in the short arc quaternions
Quaternion q2short = this->shortArc(q2);
// Interpolate using *this and q2short
q = ... {slerp from Wikipedia }
return q;
}
/// Return a quaternion which, when used in slerp, will yield quaternions on the short arc between
/// this quaternion and a specified quaternion, q2. The returned quaternion will be equal to
/// q2 or -q2 and therefore may be in non-canonical form.
template <class P> Quaternion_<P>
Quaternion_<P>::shortArc(const Quaternion_<P>& q2) const {
RealP this_dot_q2 = ~(*this) * q2;
Vec4P q(q2.asVec4());
if(this_dot_q2 < 0.0) { q = -q; }
return Quaternion_<P>(q);
}
I'd use the slerp()
method when resampling quaternions for different video frame rates and playback speeds. As a last step, I'd use the shortArc()
method to express the quaternions in a form that won't require a call to Blender's q2.make_compatible(q1). I can certainly make do without a public shortArc()
method, but it would be nice to have.
from simbody.
Hello, I am working on OpenSim and Blender. I am interested in your work on Simbody and Blender. Could I learn about what you are doing? Thanks.
from simbody.
@hwy1992129 I'd be happy to discuss my activities relating to OpenSim, Simbody, and Blender. It's probably better if you and I interact via the email address associated with my GitHub repositories: [email protected]. Feel free to send me an email, and please tell me more about your interests and activities.
from simbody.
Related Issues (20)
- Usage of SimTK::Vec for custom types. HOT 1
- Incoming PR - Improvement to ExponentialSpringForce HOT 4
- The OBJ file parser should ignore all kinds of whitespace for face (`f`) commands HOT 2
- TestBigMatrix fails on mips64el and ppc64el architectures HOT 8
- Rack Pinion Mobilizer HOT 3
- Problem when weighting integration accuracy
- TestCustomConstraints (Failed) on x86_64
- Setting output precision for String::String(const T& t) HOT 4
- "No such file or directory" HOT 6
- Visualizer crashes when drive letters don't match HOT 7
- Cannot compile in C++20 if a compilation unit uses `MultibodyGraphMaker.h`
- `getContiguousScalarData` has different behavior for `RowVector` and `RowVectorView` HOT 3
- Variable precision for String::String(const T& t) and Xml::setValueAs(const T& t) HOT 3
- Simbody Visualization not working on MacOS HOT 1
- Specifying XML output precision with an optional argument causes a bug for variables of type bool HOT 1
- TestXML fails on Windows 11, Visual Studio 2022 with a Release build. HOT 2
- Expose `SimbodyMatterSubsystemRep::multiplyByPVATranspose` to `SimbodyMatterSubsystem` HOT 2
- Visaulization HOT 1
- Simbody core aborted while using it with gazebo classic after loading a SDF. HOT 6
- Efficiently calculating a subset of a system's body and mobility forces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simbody.