Sun Nov 24 15:37:24 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2017-08-01

LEARN

2024-11-24 | 2024-10-24 | 2024-09-24 | 2024-08-24 | 2024-07-24 | 2024-06-24 | 2024-05-24 | 2024-04-24 | 2024-03-24 | 2024-02-24 | 2024-01-24 | 2023-12-24 | 2023-11-24 | 2023-10-24 | 2023-09-24 | 2023-08-24 | 2023-07-24 | 2023-06-24 | 2023-05-24 | 2023-04-24 | 2023-03-24 | 2023-02-24 | 2023-01-24 | 2022-12-24 | 2022-11-24 | 2022-10-24 | 2022-09-24 | 2022-08-24 | 2022-07-24 | 2022-06-24 | 2022-05-24 | 2022-04-24 | 2022-03-24 | 2022-02-24 | 2022-01-24 | 2021-12-24 | 2021-11-24 | 2021-10-24 | 2021-09-24 | 2021-08-24 | 2021-07-24 | 2021-06-24 | 2021-05-24 | 2021-04-24 | 2021-03-24 | 2021-02-24 | 2021-01-24 | 2020-12-24 | 2020-11-24 | 2020-10-24 | 2020-09-24 | 2020-08-24 | 2020-07-24 | 2020-06-24 | 2020-05-24 | 2020-04-24 | 2020-03-24 | 2020-02-24 | 2020-01-24 | 2019-12-24 | 2019-11-24 | 2019-10-24 | 2019-09-24 | 2019-08-24 | 2019-07-24 | 2019-06-24 | 2019-05-24 | 2019-04-24 | 2019-03-24 | 2019-02-24 | 2019-01-24 | 2018-12-24 | 2018-11-24 | 2018-10-24 | 2018-09-24 | 2018-08-24 | 2018-07-24 | 2018-06-24 | 2018-05-24 | 2018-04-24 | 2018-03-24 | 2018-02-24 | 2018-01-24 | 2017-12-24 | 2017-11-24 | 2017-10-24 | 2017-09-24 | 2017-08-24 | 2017-07-24 | 2017-06-24 | 2017-05-24 | 2017-04-24 | 2017-03-24 | 2017-02-24 | 2017-01-24 | 2016-12-24 | 2016-11-24 | 2016-10-24 | 2016-09-24 | 2016-08-24 | 2016-07-24 | 2016-06-24 | 2016-05-24 | 2016-04-24 | 2016-03-24 | 2016-02-24 | 2016-01-24 | 2015-12-24 | 2015-11-24 | 2015-10-24 | 2015-09-24 | 2015-08-24 | 2015-07-24 | 2015-06-24 | 2015-05-24 | 2015-04-24 | 2015-03-24 | 2015-02-24 | 2015-01-24 | 2014-12-24 | 2014-11-24 | 2014-10-24

Key: Value:

Key: Value:

MESSAGE
DATE 2017-08-26
FROM ruben safir
SUBJECT Subject: [Learn] Fwd: quaternion graphics in C or C-style C++?
From learn-bounces-at-nylxs.com Sat Aug 26 23:57:41 2017
Return-Path:
X-Original-To: archive-at-mrbrklyn.com
Delivered-To: archive-at-mrbrklyn.com
Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82])
by mrbrklyn.com (Postfix) with ESMTP id B1E28163F54;
Sat, 26 Aug 2017 23:57:40 -0400 (EDT)
X-Original-To: learn-at-nylxs.com
Delivered-To: learn-at-nylxs.com
Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89])
by mrbrklyn.com (Postfix) with ESMTP id E8948160876
for ; Sat, 26 Aug 2017 23:57:36 -0400 (EDT)
Received: from [10.0.0.62] (www.mrbrklyn.com [96.57.23.82])
by mailbackend.panix.com (Postfix) with ESMTPSA id 784CD11164;
Sat, 26 Aug 2017 23:57:36 -0400 (EDT)
From: ruben safir
To: "learn-at-nylxs.com" ,
=?UTF-8?B?15PXqNeV16gg15jXldeR15kvRHJvciBUb2Jp?=
References:
<1bziatvnhx.fsf-at-pfeifferfamily.net>
<715c4d46-45a3-08db-09cc-fcbf87de6948-at-gmail.com>

Message-ID:
Date: Sat, 26 Aug 2017 23:57:36 -0400
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1
MIME-Version: 1.0
In-Reply-To:
Content-Type: multipart/mixed; boundary="------------BABEE0D1DD631B7C690E47DE"
Content-Language: en-US
Subject: [Learn] Fwd: quaternion graphics in C or C-style C++?
X-BeenThere: learn-at-nylxs.com
X-Mailman-Version: 2.1.17
Precedence: list
List-Id:
List-Unsubscribe: ,

List-Archive:
List-Post:
List-Help:
List-Subscribe: ,

Errors-To: learn-bounces-at-nylxs.com
Sender: "Learn"

This is a multi-part message in MIME format.
--------------BABEE0D1DD631B7C690E47DE
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit


I think this is related to your work

--------------BABEE0D1DD631B7C690E47DE
Content-Type: message/rfc822;
name="quaternion graphics in C or C-style C++?"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="quaternion graphics in C or C-style C++?"

Path: reader2.panix.com!panix!goblin3!goblin2!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Melik
Newsgroups: comp.graphics.algorithms,comp.lang.c,comp.lang.c++
Subject: quaternion graphics in C or C-style C++?
Date: Sat, 19 Aug 2017 21:57:59 -0700
Organization: A noiseless patient Spider
Message-ID:
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 20 Aug 2017 04:53:44 -0000 (UTC)
Injection-Info: mx02.eternal-september.org; posting-host="72cc2729e6facf2d910d4fd5e61f53c1";
logging-data="27269"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX18ol6VSK7p11ufZ0+sAbk1pUARGDtYBUVs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.3.0
Content-Language: en-US
Cancel-Lock: sha1:KiEBf44HAqhWk/nJ8iXlo5JCKo4=
Xref: panix comp.graphics.algorithms:176879 comp.lang.c:1115409 comp.lang.c++:1131237

I'm interested learning how quaternions simplify three-dimensional (3D)
graphics programming, such as for a wireframe cube in C or C-style C++
(which I've programmed before, and is on my homepage for GCC C++ w/SDL,
maybe modifiable to C, and has a simple BSD-style license,) doing all
the details, i.e., not using libraries (except, perhaps put_pixel() and
line(), not even some matrix library, let alone graphics ones doing it
all for you.)

I.e., the only thing I'd want to use from C++ for this (since I'm trying
to learn more C and linear algebra) is in the case in C++ you can set
your matrix's values all at once, rather than I recall, in C, I had to
do one element at a time. So, I want to be able to comment out that
one-line assignment, and write C-style multiple lines, if I want to
save as a .C instead of .CC.

I combined the three standard 3x3 3D rotation matrices into one in which
I can input angles I want, then multiplied it by my 3x8 matrix of the
cube vertices (actually one by one, with a for-loop,) and after doing
perspective and displaying the cube, iterated through time (t) to move
the cube. But, I recall from a university math club lecture,
quaternions already have (x,y,z) defined for all t with respect to
whatever 3D rotation angles you use.

So, I'd like to know, how can quaternions simplify this process? I
recall they're something like a scalar on some (x,y,z) but forgot how
that would seem to simplify any multiplication or iteration.

Rather than in one suggestion I was given, saying break this down into
more objects such as vertex vectors and a rotation matrix with twice as
many angles than I need, I'd still prefer to use an object matrix
(defining my cube's vertices,) and rotation matrices (and saw at least a
couple different types, maybe still with several of each that could be
multiplied,) but if there's a way to do either fewer matrix
multiplications, or not so much iteration, that would be a benefit... is
that what one could do with quaternions? Or, is there some simpler way,
that will still reduce the amount of code you need to write, and amount
of variables/objects you need to use, as well as the calculations?

David (Darwin in USA code/math/graphics/art/music Demoscene)
http://www.cwu.edu/~melikd/


--------------BABEE0D1DD631B7C690E47DE
Content-Type: message/rfc822;
name="Re: quaternion graphics in C or C-style C++?"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Re: quaternion graphics in C or C-style C++?"

Path: reader2.panix.com!panix!goblin1!goblin2!goblin.stu.neva.ru!peer03.am4!peer.am4.highwinds-media.com!peer01.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx20.am4.POSTED!not-for-mail
Subject: Re: quaternion graphics in C or C-style C++?
Newsgroups: comp.graphics.algorithms,comp.lang.c,comp.lang.c++
References:
From: bartc
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1
MIME-Version: 1.0
In-Reply-To:
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
Message-ID:
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Sun, 20 Aug 2017 11:21:26 UTC
Organization: virginmedia.com
Date: Sun, 20 Aug 2017 12:21:26 +0100
X-Received-Bytes: 4335
X-Received-Body-CRC: 2055951395
Xref: panix comp.graphics.algorithms:176880 comp.lang.c:1115418 comp.lang.c++:1131242

On 20/08/2017 05:57, David Melik wrote:
> I'm interested learning how quaternions simplify three-dimensional (3D)
> graphics programming, such as for a wireframe cube in C or C-style C++
> (which I've programmed before, and is on my homepage for GCC C++ w/SDL,

(http://www.cwu.edu/~melikd/math/demosrc/demo.cpp)

> maybe modifiable to C, and has a simple BSD-style license,) doing all
> the details, i.e., not using libraries (except, perhaps put_pixel() and
> line(), not even some matrix library, let alone graphics ones doing it
> all for you.)

One comment:

//define polyhedra
int cube_100[3][8]={{-50, -50, 50, 50, -50, -50, 50, 50},
{-50, 50, 50, -50, -50, 50, 50, -50},
{-50, -50, -50, -50, 50, 50, 50, 50}};
int cube_a[3][8]={{-50, -50, 50, 50, -50, -50, 50, 50},
{-50, 50, 50, -50, -50, 50, 50, -50},
{-50, -50, -50, -50, 50, 50, 50, 50}};

This looks rather peculiar; is each (x,y,z) point represented as a
vertical column here?

It is more normal to store x, y and z together, for example (also using
floats rather than ints, but I don't know if the above is a requirement
of SDL):

typedef struct { float x,y,z;} Point;

Point cube[8] = {
{-50, -50, -50},
{-50, 50, -50},
etc

Then, if vertices of a cube are indexed 0 to 7, the Z component of
vertex 4 would be:

cube[4].z

(Your code which uses indices for both, and in a backwards order, gets
confusing later on.)

> So, I'd like to know, how can quaternions simplify this process? I

(Can't help there; don't know quaternions.)

> recall they're something like a scalar on some (x,y,z) but forgot how
> that would seem to simplify any multiplication or iteration.
>
> Rather than in one suggestion I was given, saying break this down into
> more objects such as vertex vectors and a rotation matrix with twice as
> many angles than I need, I'd still prefer to use an object matrix
> (defining my cube's vertices,) and rotation matrices (and saw at least a
> couple different types, maybe still with several of each that could be
> multiplied,) but if there's a way to do either fewer matrix
> multiplications,

How many were you thinking of? A cube has 8 corners, so would need 8
transformations (applying a transformation matrix to each point to yield
a new point).

You only need to multiply matrices to combine transformations. That's
done once then you can apply the same result to any number of points
(ie. vertices).

Not sure about all the things your code does; one part seems to rotate a
2D cube 360 degrees, 6 degrees at a time so 60 (or 61) rotations are
applied.

To do similar with a 3D cube, which has 8 corners, you might try this
for each iteration:

Set up a new rotation matrix for this new angle
Copy the 8 vertices into a new cube
Apply the matrix on the new cube
Draw it (presumably using 12 edges between 12 pairs of those 8 vertices)

This is compared with, for example, taking an edge at a time, and
transforming the two endpoints, as you will do 24 transformations rather
than 8.

A faster way of rotating such a cube is to set up a rotation matrix for
6 degrees. Take a copy of the original cube. Then:

Draw the cube
Apply the 6 degree rotation to each of the 8 vertices
Repeat 60 times

So this avoids copying vertices, or re-calculating the rotation matrix.
But incremental errors can build up.

--
bartc



--------------BABEE0D1DD631B7C690E47DE
Content-Type: message/rfc822;
name="Re: quaternion graphics in C or C-style C++?"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Re: quaternion graphics in C or C-style C++?"

Path: reader2.panix.com!panix!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Joe Pfeiffer
Newsgroups: comp.graphics.algorithms,comp.lang.c,comp.lang.c++
Subject: Re: quaternion graphics in C or C-style C++?
Date: Sun, 20 Aug 2017 17:16:26 -0600
Organization: A noiseless patient Spider
Message-ID: <1bziatvnhx.fsf-at-pfeifferfamily.net>
References:
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: mx02.eternal-september.org; posting-host="fdb626606ce42fa459b961f8fc2e634b";
logging-data="24692"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX18afMJaNqdsX3rbz2++86bEY8Eqe++XeAE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
Cancel-Lock: sha1:47HtpQoeDKjJjtPCbgd2yW+Lu/g=
sha1:CnZglGjs4qraTOwc5vjfiI+9VSo=
Xref: panix comp.graphics.algorithms:176881 comp.lang.c:1115452 comp.lang.c++:1131257

David Melik writes:

> I'm interested learning how quaternions simplify three-dimensional
> (3D) graphics programming, such as for a wireframe cube in C or
> C-style C++ (which I've programmed before, and is on my homepage for
> GCC C++ w/SDL, maybe modifiable to C, and has a simple BSD-style
> license,) doing all the details, i.e., not using libraries (except,
> perhaps put_pixel() and line(), not even some matrix library, let
> alone graphics ones doing it all for you.)
>
> I.e., the only thing I'd want to use from C++ for this (since I'm
> trying to learn more C and linear algebra) is in the case in C++ you
> can set your matrix's values all at once, rather than I recall, in C,
> I had to do one element at a time. So, I want to be able to comment
> out that one-line assignment, and write C-style multiple lines, if I
> want to save as a .C instead of .CC.
>
> I combined the three standard 3x3 3D rotation matrices into one in
> which I can input angles I want, then multiplied it by my 3x8 matrix
> of the cube vertices (actually one by one, with a for-loop,) and after
> doing perspective and displaying the cube, iterated through time (t)
> to move the cube. But, I recall from a university math club lecture,
> quaternions already have (x,y,z) defined for all t with respect to
> whatever 3D rotation angles you use.
>
> So, I'd like to know, how can quaternions simplify this process? I
> recall they're something like a scalar on some (x,y,z) but forgot how
> that would seem to simplify any multiplication or iteration.
>
> Rather than in one suggestion I was given, saying break this down into
> more objects such as vertex vectors and a rotation matrix with twice
> as many angles than I need, I'd still prefer to use an object matrix
> (defining my cube's vertices,) and rotation matrices (and saw at least
> a couple different types, maybe still with several of each that could
> be multiplied,) but if there's a way to do either fewer matrix
> multiplications, or not so much iteration, that would be a
> benefit... is that what one could do with quaternions? Or, is there
> some simpler way, that will still reduce the amount of code you need
> to write, and amount of variables/objects you need to use, as well as
> the calculations?
>
> David (Darwin in USA code/math/graphics/art/music Demoscene)
> http://www.cwu.edu/~melikd/
>

If you're looking for what I think you are, search on affine
transformation matrices. The wikipedia page
https://en.wikipedia.org/wiki/Transformation_matrix appears at first
glance to give a good introduction; it's also a chapter in just about
any computer graphics textbook.


--------------BABEE0D1DD631B7C690E47DE
Content-Type: message/rfc822;
name="Re: quaternion graphics in C or C-style C++?"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Re: quaternion graphics in C or C-style C++?"

Path: reader2.panix.com!panix!goblin3!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Melik
Newsgroups: comp.graphics.algorithms,comp.lang.c,comp.lang.c++
Subject: Re: quaternion graphics in C or C-style C++?
Date: Wed, 23 Aug 2017 02:57:56 -0700
Organization: A noiseless patient Spider
Message-ID: <715c4d46-45a3-08db-09cc-fcbf87de6948-at-gmail.com>
References:
<108ebbab-3f98-4a3d-853e-e453ddb1a8dd-at-googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: mx02.eternal-september.org; posting-host="82ca12dfd24494ad9ecc51e134e15793";
logging-data="6332"; mail-complaints-to="abuse-at-eternal-september.org"; posting-account="U2FsdGVkX19DTk8Zv/8upbuTyYWBdSKTfPml354XcSE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.3.0
In-Reply-To: <108ebbab-3f98-4a3d-853e-e453ddb1a8dd-at-googlegroups.com>
Content-Language: en-US
Cancel-Lock: sha1:oiIW5oiHC3g7IQ0LaGUORJ/nEn4=
Xref: panix comp.graphics.algorithms:176882 comp.lang.c:1115631 comp.lang.c++:1131307

(reply below is on Usenet and 'blind carbon copy' (BCC) to a listserv)

On 08/21/2017 05:12 AM, SG wrote:
> On Sunday, August 20, 2017 at 6:58:21 AM UTC+2, David Melik wrote:
>>
>> So, I'd like to know, how can quaternions simplify this process? I
>> recall they're something like a scalar on some (x,y,z) but forgot how
>> that would seem to simplify any multiplication or iteration.
>
> Quaternions are useful if you need a compact representation of a 3D
> rotation matrix. Given a normalized quaternion q, it's rather easy to
> determine a corresponding rotation matrix R
>
> R = q2rot(q) (I won't bother defining q2rot)

Not define... why? If, for example, quaternions (or anything) were
being described in a pure mathematics textbook, *everything* would be
defined, probably full detail (unless left as an exercise, where at
least they'd define their terms.) It turns out I won't necessarily need
definition now (if you see my reply to your question below,) but...


> And for every rotation matrix R there are two such quaternions:
> q and -q. This q2rot functions has the following properties:
>
> q2rot(q) = q2rot(-q) and
>
> q2rot(a * b) = q2rot(a) * q2rot(b).
>
> Given the last equality and the fact that multiplying quaternions is
> cheaper than multiplying 3x3 rotation matrices, quaternions allow you
> to efficiently multiply lots of 3D rotations together. So, if you
> need to multiply lots of rotations, quaternions are going to be more
> efficient for that.
>
> However, if you want to apply the resulting rotation to a collection
> of points (like the vertices of your cube), you should probably
> convert the quaternion back to a 3x3 rotation matrix because this
> matrix representation is more efficient for such things in terms of
> number of necessary floating point operations.

Ok, so apparently they don't really improve something as basic as
rotating a cube. So, if I made a larger or generalized 3D system, they
could be useful.

For the cube I did, I combined my rotation matrices for the three angles
myself, beforehand. So, it seems, I won't achieve anything more by
replacing that.


> I think that answers your question?

Part of it (and all most important parts for now.) I still want to
learn quaternions for a 3D C or C-style C++ program, and now have a
better overview (not details)... but you've clarified, I should try a 3D
thing they're more useful for, first, or just a calculation program.
So, I'll have to choose which way to continue, before any more detailed
questions.

That's all for now on on Usenet from me.


------------------------------------------------------------------------
Note to listserv I sent this to (after recent discussion.) Double-check
any reply you write won't also have Usenet newsgroups in 'To:,' unless
desired (probably will only be 'To:' me, but I forgot how it works when
you post to a listserv & Usenet both.) My original post (only small
part quoted above) was to Usenet news://comp.graphics.algorithms ,
news://comp.lang.c , news://comp.lang.c++ newsgroups.


--------------BABEE0D1DD631B7C690E47DE
Content-Type: message/rfc822;
name="Re: quaternion graphics in C or C-style C++?"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
filename="Re: quaternion graphics in C or C-style C++?"

X-Received: by 10.129.141.72 with SMTP id w8mr1644058ywj.202.1503489368839;
Wed, 23 Aug 2017 04:56:08 -0700 (PDT)
Path: reader2.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!ottix-news.ottix.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!e2no2330615qta.1!news-out.google.com!r28ni28qte.0!nntp.google.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad!fx03.iad.POSTED!not-for-mail
Subject: Re: quaternion graphics in C or C-style C++?
Newsgroups: comp.graphics.algorithms,comp.lang.c,comp.lang.c++
References:
<108ebbab-3f98-4a3d-853e-e453ddb1a8dd-at-googlegroups.com>
<715c4d46-45a3-08db-09cc-fcbf87de6948-at-gmail.com>
From: Richard Damon
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0)
Gecko/20100101 Thunderbird/52.3.0
MIME-Version: 1.0
In-Reply-To: <715c4d46-45a3-08db-09cc-fcbf87de6948-at-gmail.com>
Message-ID:
X-Complaints-To: abuse-at-easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 23 Aug 2017 07:56:07 -0400
X-Received-Bytes: 4578
X-Received-Body-CRC: 1577935296
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Original-Bytes: 4434
Xref: panix comp.graphics.algorithms:176883 comp.lang.c:1115646 comp.lang.c++:1131310

On 8/23/17 5:57 AM, David Melik wrote:
> (reply below is on Usenet and 'blind carbon copy' (BCC) to a listserv)
>
> On 08/21/2017 05:12 AM, SG wrote:
>> On Sunday, August 20, 2017 at 6:58:21 AM UTC+2, David Melik wrote:
>>>
>>> So, I'd like to know, how can quaternions simplify this process?  I
>>> recall they're something like a scalar on some (x,y,z) but forgot how
>>> that would seem to simplify any multiplication or iteration.
>>
>> Quaternions are useful if you need a compact representation of a 3D
>> rotation matrix.  Given a normalized quaternion q, it's rather easy to
>> determine a corresponding rotation matrix R
>>
>>    R = q2rot(q)   (I won't bother defining q2rot)
>
> Not define... why?  If, for example, quaternions (or anything) were
> being described in a pure mathematics textbook, *everything* would be
> defined, probably full detail (unless left as an exercise, where at
> least they'd define their terms.)  It turns out I won't necessarily need
> definition now (if you see my reply to your question below,) but...
>
>
I think he meant that he wasn't going to write out the code for q2rot().
Quaternions are well defined mathematically, and the creation of q2rot()
is a mostly mechanical process of looking at the definition and putting
it to code.

>> And for every rotation matrix R there are two such quaternions:
>> q and -q. This q2rot functions has the following properties:
>>
>>    q2rot(q) = q2rot(-q)  and
>>
>>    q2rot(a * b) = q2rot(a) * q2rot(b).
>>
>> Given the last equality and the fact that multiplying quaternions is
>> cheaper than multiplying 3x3 rotation matrices, quaternions allow you
>> to efficiently multiply lots of 3D rotations together.  So, if you
>> need to multiply lots of rotations, quaternions are going to be more
>> efficient for that.
>>
>> However, if you want to apply the resulting rotation to a collection
>> of points (like the vertices of your cube), you should probably
>> convert the quaternion back to a 3x3 rotation matrix because this
>> matrix representation is more efficient for such things in terms of
>> number of necessary floating point operations.
>
> Ok, so apparently they don't really improve something as basic as
> rotating a cube.  So, if I made a larger  or generalized 3D system, they
> could be useful.
>
> For the cube I did, I combined my rotation matrices for the three angles
> myself, beforehand. So, it seems, I won't achieve anything more by
> replacing that.
>
Quaternions provide a compact notation for representing an orientation,
and a fairly simple way to chain rotations. For actually doing the
rotations to lots of objects, the simple rotation matrix can be
simpler/faster (so converting the Quaternion to a matrix near the end
makes sense). One other factor is computational stability, chaining
Quaternions can't mess up the scale of orthogonality of the axes, while
with a rotation matrix, the round off errors in each operation can
gradually build up to cause these sorts of errors,
>
>> I think that answers your question?
>
> Part of it (and all most important parts for now.)  I still want to
> learn quaternions for a 3D C or C-style C++ program, and now have a
> better overview (not details)... but you've clarified, I should try a 3D
> thing they're more useful for, first, or just a calculation program. So,
> I'll have to choose which way to continue, before any more detailed
> questions.
>
> That's all for now on on Usenet from me.
>
>


--------------BABEE0D1DD631B7C690E47DE
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn

--------------BABEE0D1DD631B7C690E47DE--

  1. 2017-08-03 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] age discrimination in IT
  2. 2017-08-04 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] the tip of the precipice.
  3. 2017-08-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] computational palaeobiology
  4. 2017-08-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Language theory
  5. 2017-08-15 From: "Yi Qian, IEEE ICC'18 TPC Chair" <noreply-at-comsoc.org> Subject: [Learn] IEEE ICC'18 Tutorial Proposals due 15 September 2017
  6. 2017-08-15 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] P is not equal to NP
  7. 2017-08-15 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] unsupervised-learning
  8. 2017-08-16 Richard Stallman <rms-at-gnu.org> Re: [Learn] P is not equal to NP
  9. 2017-08-26 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: quaternion graphics in C or C-style C++?

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!