vsg-dev / vsgExamples

Example programs that test and illustrate how to use the VSG and optional add-on libraries
MIT License
148 stars 67 forks source link

about quaternion #114

Closed MasonAlice closed 3 years ago

MasonAlice commented 3 years ago

why the math library does not include these?

template<typename T>
t_quat<T> rotate(T angle_radians, const t_vec3<T>& v);

template<typename T>
constexpr t_vec3<T> operator*(const t_vec3<T>& v);
robertosfield commented 3 years ago

Hi Howell,

On Tue, 5 Oct 2021 at 07:29, Howell @.***> wrote:

why the math library does not include these?

template t_quat rotate(T angle_radians, const t_vec3& v);

There is a vsg::rotate(T angle_radians, const t_vec3& v) but it directly converts to tvsg::t_mat4. We can't provide both so one has to choose which one is more widely useful.

Looking at include/vsg/maths/quat.h I see that we don't yet have a vsg::t_quat constructor that takes (T angle_radians, const t_vec3& v) so that is is possible addition that can provide a convenient way of creating a vsg::quat.

templateconstexpr t_vec3 operator*(const t_vec3& v);

GLSL has a component-wise multiplication so this would be a natural thing to add.

I'm in the middle of some other work, so if you can't wait for me to get to them feel free to add them and generate a PR.

Cheers, Robert.

robertosfield commented 3 years ago

Hi Howel,

FYI, I've recently checked in some working adding vsg::AnimationPath class to the VulkanSceneGraph, as part of this work I've added a vsg::quat constructor and vsg::quat::set(..) method that takes a angle and axis, and ones that take two vectors, computing the quat that rotates between the vectors.

This is now checked into VSG master.

Robert.

robertosfield commented 3 years ago

I have now checked in vec2, vec3 and vec4 variants on the vec vec and vec = vec operators.

ef2478471e8d6bf5f94cd939b613f03b745418fc

With this change I believe all the items you mentioned are now resolved so will close this issue.