 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
OK, the way I see it is that you need to take the atan2 of your _distance_
between the 2 points and the x or y value of the look_at
The key is that you need to take into account the x AND y variation of your
vector when you calculate the x and y angles. So use the whole vector length
in your atan2 function.
so, that would be something like
degrees(atan2(Vlength(LA-Cam), LA.x)) and degrees(atan2(Vlength(LA-Cam), LA.y))
or expanded:
degrees( atan2 ( sqrt( ((LA.x-Cam.x)^2)+((LA.y-Cam.y)^2)+((LA.z-Cam.z)^2) ),
LA.x ))
degrees( atan2 ( sqrt( ((LA.x-Cam.x)^2)+((LA.y-Cam.y)^2)+((LA.z-Cam.z)^2) ),
LA.y ))
(worked out in OpenOffice, so they _may_ some editing need (like the N^2
notation) )
Good luck, YMMV :D
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 31/05/2017 07:06, dick balaska wrote:
> Am 2017-05-29 15:42, also sprach dick balaska:
>> I'm trying to master converting a vector to an angle in 3D with no luck
>
> Help, Math wizards, you're my only hope.
>
> Ok. I'm stuck. I'm missing something.
>
> My goal is to position an object in a fixed position on the screen, like
> carrying a flashlight. Or a gun, like in a video game.
>
> So I need to calculate the angle of Lookat-Camera and act on that.
>
> My primary macro works, but I'm missing something in determining the
> position of an object that is not exactly on the look_at. I can't
> figure out if I need to subtract an angle or a vector or from whom.
> For example, in this screen shot,
> http://www.buckosoft.com/tteoac/video/testRenders/test001.png
> the red ball is look_at,
> the cyan ball is the angle correctly derived from (look_at-camera),
> but the green ball is only correctly 1 unit horizontally to the right of
> the cyan ball for this angle <0,0,0>. Otherwise it spins incoherently
> (to me) around the cyan ball. Interestingly, it keeps the correct distance.
> http://www.buckosoft.com/tteoac/video/testRenders/test.mp4
>
> argh. I keep trying to work it out on paper, but I'm not feeling it.
Try the attached.
Post a reply to this message
Attachments:
Download 'test16.pov.txt' (3 KB)
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Oh, a single rotational angle.
That makes sense.
I wasn't sure what he was after - it's hard to tell with something symmetric
like a sphere.
I'm guessing he wants to avoid:
http://www.mathwords.com/a/angle_depression.htm
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 2017-05-31 12:07, also sprach scott:
> On 31/05/2017 07:06, dick balaska wrote:
>> Help, Math wizards, you're my only hope.
> Try the attached.
Yeah baby! There's nothing like a copy/paste solution that I almost
understand, but does exactly what I want. ;)
I can't wait to try it out on non-solid, non-spherical shapes.
Thanks!
--
dik
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 2017-05-31 07:52, also sprach Bald Eagle:
>> argh. I keep trying to work it out on paper, but I'm not feeling it.
>
> I have been there SO many times.
One of my favorites was, my wife took a picture of me with my chin on
the dining room table, playing with a Lego cow and a ruler. Which, if
you've seen my animation of the running non-articulated horses, you'll
understand what I was trying to accomplish. ;) Usually, it's just paper
with random circles and triangles and lines and points.
She: "Do you understand any of that?"
Me: "Not really."
--
dik
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
dick balaska <dic### [at] buckosoft com> wrote:
> One of my favorites was, my wife took a picture of me with my chin on
> the dining room table, playing with a Lego cow and a ruler. Which, if
> you've seen my animation of the running non-articulated horses, you'll
> understand what I was trying to accomplish. ;)
I can't tell you how many things I measure on a regular basis.
Rulers, tape measures, eye-and-thumb, protractor, or back-estimating from
photos....
Speaking of Legos - you ought to check out the Antikythera mechanism this guy
built entirely from Lego. :O
> Usually, it's just paper
> with random circles and triangles and lines and points.
Yes. I have piles and piles of paper with lines and circles and ellipses and
triangles, and then there are the ones where there's a rat's nest of curves and
5 pages of equations...
"WTF are you ***DOING***????!!!"
"Well, ..."
"No. never mind. OMG."
:D
BTW
I think if you just look at the rotation angle like a clock hand on the screen,
centered around your camera location, then all you're doing is calculating the
angle, given the x and y coordinates.
So that's just degrees ( atan2(LookAt.y-Cam.y, LookAt.x-Cam.x) )
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> Help, Math wizards, you're my only hope.
>
>> Try the attached.
>
> Yeah baby! There's nothing like a copy/paste solution that I almost
> understand, but does exactly what I want. ;)
> I can't wait to try it out on non-solid, non-spherical shapes.
>
> Thanks!
:-)
What you're trying to do is transform some kind of "screen" coordinates
into world coordinates. What I did was to calculate the directions of
the "new" x,y,z axes and then use those to transform the original
coordinate to the actual world coordinate:
> #local newZ = vnormalize( Lookat-Camera );
The new Z axis direction should be from Camera to Lookat, this is what
you want. vnormalize makes sure it's a unit length vector.
> #local newY = y;
The new Y axis direction is just y to start (it will be fixed later).
> #local newX = vnormalize(vcross(newY,newZ));
The new X axis direction is perpendicular to the Z and Y defined in the
above two lines (ie to the right). X and Z are now correct, but Y needs
to be adjusted to take account of Z probably not being horizontal (Y
needs to be "tipped back" a bit).
> #local newY = vnormalize(vcross(newZ,newX));
The new Y is now calculated as perpendicular to the Z and X just
calculated. This is correct now, with all 3 perpendicular to each other.
> #local bar = bar.x * newX + bar.y * newY + bar.z * newZ;
This line essentially takes the original xyz coordinates and transforms
them using the new XYZ axes. There are neater ways to do this, but I
thought this made it a little more clear what is going on.
Note the new coordinates are relative to the camera, so you still need
the translate camera line.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 05/29/2017 03:42 PM, dick balaska wrote:
> Help, Math wizards, you're my only hope.
I have started again to try to tackle this problem.
Scott's solution gave me a vector, which is not what I need. :( I need
an angle.
http://www.buckosoft.com/tteoac/video/testRenders/test2.mp4
The first 3 moves are correct, when I move x or z. As soon as I move
both, all hell breaks loose.
The kid in my movie is carrying a flashlight. It has an offset of
<-0.4,-0.3,0.7> from the origin and points down the Z.
The red ball is Lookat.
I have the angle between Lookat-Camera shown by the cyan ball.
It seems to me that if I move my flashlight to its offset, rotate it by
the Lookat-Camera angle, then add the Camera vector, it SHOULD BE LOCKED
TO THE CAMERA.
argh.
Post a reply to this message
Attachments:
Download 'test2.pov.txt' (5 KB)
Download 'animtest.ini.txt' (1 KB)
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
dick balaska <dic### [at] buckosoft com> wrote:
> On 05/29/2017 03:42 PM, dick balaska wrote:
>
> > Help, Math wizards, you're my only hope.
>
> I have started again to try to tackle this problem.
>
> Scott's solution gave me a vector, which is not what I need. :( I need
> an angle.
>
> http://www.buckosoft.com/tteoac/video/testRenders/test2.mp4
>
> The first 3 moves are correct, when I move x or z. As soon as I move
> both, all hell breaks loose.
>
> The kid in my movie is carrying a flashlight. It has an offset of
> <-0.4,-0.3,0.7> from the origin and points down the Z.
> The red ball is Lookat.
> I have the angle between Lookat-Camera shown by the cyan ball.
>
> It seems to me that if I move my flashlight to its offset, rotate it by
> the Lookat-Camera angle, then add the Camera vector, it SHOULD BE LOCKED
> TO THE CAMERA.
>
> argh.
So, just so I fully understand what you want,
1. You want to have a flashlight that always points at "Lookat"
2. You want it offset by a certain amount from the camera position
3. ... ? (if any)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 12/15/2017 07:50 AM, Bald Eagle wrote:
> argh.
>
> So, just so I fully understand what you want,
> 1. You want to have a flashlight that always points at "Lookat"
> 2. You want it offset by a certain amount from the camera position
>
> 3. ... ? (if any)
Yes, like in Doom, where the gun is in a fixed position relative to the
game window.
(Wait, isn't there a text thingy in the object library that draws text
in a fixed position on the screen? ...)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |