POV-Ray : Newsgroups : povray.tools.general : vector direction turned into rotation angles : Re: vector direction turned into rotation angles Server Time
8 Feb 2023 09:33:14 EST (-0500)
  Re: vector direction turned into rotation angles  
From: clipka
Date: 8 Oct 2018 13:34:38
Message: <5bbb952e@news.povray.org>
Am 06.10.2018 um 09:12 schrieb Kenneth:

> Honestly, I would say that I understand maybe half of those things, from a
> conceptual/3-D spatial viewpoint (my preferred or ONLY way of thinking about
> math concepts.) Others like dot-products I have a really hard time visualizing.
> And of the ones that I *do* understand, I'm just not sure how or when to use
> some of them. THAT's quite frustrating-- to know that they are useful, but to
> not know when to apply them.

Speaking of dot product...

> VAngle(V1, V2), VAngleD(V1, V2)-- Compute the angle between two vectors.
> 
> VCos_Angle(V1, V2)-- Compute the cosine of the angle between two vectors.
> 
> [hey, where's VSin_Angle(V1 V2) ??]

Because `VCos_Angle` is more fundamental (see below) - even more
fundamental than `VAngle`.

> VProject_Plane(V1, Axis)-- Project vector V1 onto the plane defined by Axis.
> [Uh, then what? Does it return a length? A vector?]

A vector.

In essence, the "portion" of `V1` that is perpendicular to `Axis`.
Or what is left of `V1` if you take away the component in the direction
of `Axis`.

For example, if `Axis` would happen to be +z or -z, the result would be
equal to `<V1.x,V1.y,0>`; or if `Axis` would happen to be +x or -x, the
result wold be equal to `<0,V1.y,V1.z>`; and so on.


> ..... but their actual operations still appear a bit mysterious to me. Maybe it's
> the rather terse 'textbook' descriptions that give me a hard time, I dunno.

The core building block of these all happens to be the dot product.

For me, the key property of the dot product is as follows:

Suppose you have a /unit-length/ vector A specifying a direction, and an
arbitrary vector B:

  ______ ..........__
   |    /:\ |       /\
   |  Ba :__|90    / B
   |     :        /
   |    /|\      /
   |   A |      /
  L|     |     /
   |     |    /
   |     |   /
   |     |  /
   |     | /
   |     |/
  ------ *

(The orientation of A may be aribtrary; it's only axis-aligned here
because it makes ASCII art easier ;))

Then picture a right-angled triangle as drawn above, with B as the
longest leg (hypotenuse for the initiated), and one of the other legs
(one of the catheti) in the /direction/ of A.

Then the dot product of A and B gives you the length L of the A-aligned
leg - in other words, the distance between the common corner and the
right-angled corner.


(Remember, this only works if A is of unit length; otherwise, the dot
product grows or shrinks proportional to the length of A; not sure where
one would explout that - to me it is just a nuisance.)


This property can be put to good use in the following ways:

- Dividing L (the dot product) by the length of B gives the cosine of
the angle between the two vectors. (Or, if B is also of unit length, the
dot product /is/ the cosine.)

This is what `VCos_Angle` and `VAngle` use.[*]

- Multiplying A by L (the dot product) gives us the vector from the
common corner to the right-angled corner of the triangle (Ba in the
above diagramoid) - the component of B that is co-linear with A, if you
will. Or the projection of B onto A.

This is what `VProject_Plane` uses[*], by subtracting this vector Ba
from B, thus getting the component of B that is perpendicular to A.


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.