• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Lars W.

Vector Rotation Problem

8 posts in this topic

Hi The Situation is the following: I have an Object which points into an Direction (dir). Now i want that this Object points into another Direction (newdir). But the Object can only be rotated around two axes, the upvector (up) and the sideVector (side) The Problem is, that i need the arcs for each of the two rotations (upRot),(sideRot) to make some movement restrictions. I can get one of the angles, without any Problems, but i can''t get the second one. (But maybe it is stupid simple and there is something sitting in my head eating all my knowledge) Lars
0

Share this post


Link to post
Share on other sites
If I understand you correctly, you wish to translate from your original vector (dir) to an arbitrary new direction (newdir) using only vertical and horizontal rotation (like a tank turret that can swivel side-to-side and raise/lower its aim). Okay:

dir = [x, y, z]
origin = [0, 0, 0]
newdir = [x'', y'', z'']

Rotation about the Up vector:
x-0-x'' form the angle you wish to rotate about the Up vector of your object. Obtain this angle by dividing the dot product of the vectors [x] and [x''] by the product of their magnitudes and then taking the inverse cosine (ie, [x]*[x''] = |x||x''|cos(theta), where theta is the angle sought). Then form a rotation matrix using that angle (the value is in radians) and go ahead. The rotation matrix will scale y and z appropriately.

Rotation about the Perpendicular axis:
(I''m calling the three axes Up , Forward and Perpendicular ). Assuming the Perpendicular is analogous to the Z-axis, simply replace [x] and [x''] above with [z] and [z''] and presto!

Both of the transformations describe must preceed the world transformation or be individually multiplied by it.
0

Share this post


Link to post
Share on other sites
First of all let me say that vector math has always given me problems. That said I just want to know if this will work, not if it''s efficient. Could you calculate the angles of both vectors then just rotate the first vector by the difference of the two vectors? It seems logical to me, but like I said vector math is tough for me.


Later,
Eck
0

Share this post


Link to post
Share on other sites
No, you don''t want to do that for two reasons:

The first is the most important - it won''t give you the desired result. The two vectors lie in different planes - they rotate you in different directions (actually perpendicular planes to each other). Sorry, dude.

The second is that he explicitly wants to do one first, then the other. If, however, he just wanted a straight rotation from vector A to B, he could concatenate a single matrix that had the two angles in different columns.

Hope that helps a bit. Vector math isn''t hard at basic 3D graphics levels - constrained to 3 dimensions. It starts to get complex with n .
0

Share this post


Link to post
Share on other sites
I have Problems understanding your Syntax, what does x-0-x'' mean, and what is the Vector you referring as [x] and [x''].
And finally i don''t see, where the UP-Vector comes in.

Maybe it is just the English or my reduced understanding of mathematical expressions.

Thanks in advance

Lars
0

Share this post


Link to post
Share on other sites
Sorry about that. x-0-x'' would be the angle formed by the points x (from the original vector), 0 (from the origin) and x'' (from the destination vector), lying in the XZ plane (where X is left-to-right, Y is bottom-to-top [UP] and Z is out-to-in - in other words, a left-handed coordinate system).

[x] and [x''] are 2D vectors in XZ (singe the angle lies in a natural plane, it is only necessary to consider 2 dimensions), ie (x,z) and (x'',z''). Their dot product would be

[x]*[x''] = (x * x'' + z * z'')

and their magnitudes would be

|x| = sqrt( x * x + z * z)
|x''| = sqrt( x'' * x'' + z'' * z'')

So since [x]*[x''] = |x||x''|cos(theta),
cos(theta) = ([x]*[x''])/(|x||x''|)
=> (x * x'' + z * z'')/(sqrt( x * x + z * z) * sqrt( x'' * x'' + z'' * z'')) = c
theta = acos(c)

Similar results are obtained for the vertical angle, though I did make a huge mistake. Rotation about the perpendicular axis (Z) is in terms of y, not z, so the vectors should be [y] (=(x,y)) and [y''] (=(x'',y'')).

If this doesn''t clear it up enough, post again! I''ll keep trying until I can explain myself in plain English. Good luck!
0

Share this post


Link to post
Share on other sites
Thanks alot Oluseyi

This works for me, (after transforming dir and newdir to coordiante System represented by up, side and cross(up,side))

And i meant, that my english understanding is awful, not your english writing.

Until next time, i have some Realistic maneuvering of Spaceships for the next show, when i finished the issue with the turrets :-)

Lars
0

Share this post


Link to post
Share on other sites
Keep the questions coming! It gives me something to do and an opportunity to think and problem solve (I''m not working as a programmer right now, so I''m bored stiff!) Physics, pseudo-AI and interaction are my favorite parts of game programming, because they determine the quality of gameplay, to my mind.

Looking forward to the Realistic Spaceship motion!
0

Share this post


Link to post
Share on other sites
Ok then,i can describe my idea, but i will post a new thread when i have a detailed question, first i try to solve it my self.

My main idea for the spaceship movement is, that my AI gives just a command including a movement direction, desired speed and a direction where it want''s to point to.

This command goes to the ship object. The ship object has many engines pointing in different directions, with different thrustpowers. Now i wan''t to compute how much thrust each engine should give to achieve the wished command.
And after that i need to compute the movement result that occurs from enabling the thrusters.

Lars
0

Share this post


Link to post
Share on other sites