• 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.

Wrathnut

[java] Rotation about a point

7 posts in this topic

I have what seems to be a farily simple question.. although I spent all weekend digging through my calc books to no avail.... Anyway here goes: Does anyone know a formula that allows you to rotate a point about another arbitrary point?(in 2d) I wrote an algorithm, but it only works at points close to zero... Also, Does anyone know how to rotate a point about another arbitrary point in 3d? War doesn't determine who is right, war determines who is left.
0

Share this post


Link to post
Share on other sites
ok, i did this once. let me see if i can remember


int x1,y1,x2,y2; //x1,y1 is axis x2,y2 is point u are trying to move


float dist=sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );


float angle=atan( (y2-y1)/(x2-x1) );

//u need to get the real angle from this since there are 4 angles in a circle that will give any one tangent


find what cuadrent x2,y2 are in if x1,y1 is the origin then use the angle from atan and other stuff to get angle

angle=the angle is now the correct angle from x1,y1 to x2,y2;

angle+=rotation_angle;//how far u want to rotate it


//get back into x,y coords from polar
x2=cos(angle)*dist;
y2=sin(angle)*dist;


done, hope this helps

Infested Furby Software

infestedfurby@hotmail.com
infestedfurby.cjb.net
0

Share this post


Link to post
Share on other sites
You can do rotations simply as a matrix multiplication. Do not use atan and sqrt and other slow functions.

I just lent out my book but I recommend reading a book on graphics theory. I can recommend the very classic and very excellent book

[Foley] Foley, J., van Dam, A, Feiner, S. & Hughes, J. F.: Computer Graphics. Principles and Practice. 2nd Edition in C. Addison-Wesley. 1996.

After reading this you will know everything you want to know in this subject. And if you need more advanced topics you can read

Watt, Alan H., and Mark Watt, Advanced Animation and Rendering Techniques,
Addison-Wesley, 1992.

From here you will have to read SIGGRAPH articles to know more.

Jacob Marner
0

Share this post


Link to post
Share on other sites
All you need to do is rotate it around 0, and then translate that rotation to the arbitrary point that you mentioned earlier... Make sense? It is really quite logical when you think about it

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-Chris Bennett of Dwarfsoft
"The Philosophers' Stone of Programming Alchemy"
IOL (The list formerly known as NPCAI) - A GDNet production
Our Doc - The future of RPGs
Thanks to all the goblins over in our little Game Design Corner niche
          
0

Share this post


Link to post
Share on other sites
Java2D gives you a really easy way to do translation, rotation and scaling with its AffineTransform construct. Makes it almost trivial. Java3D gives you similar capabilities.

Here''s the Java2D Tutorial, for starters:
http://java.sun.com/docs/books/tutorial/2d/index.html

I highly, highly recommend using Java2D for 2D graphics in Java applications.
0

Share this post


Link to post
Share on other sites
Hey guy's, Thanks for all of the replies to this post. I procurred a linear algebra book from one of my engineering teachcers the other day and found this equation:

X' = x*cos(theta) - y*sin(theta)
Y' = x*sin(theta) + y*cos(theta)

where theta is the angle that you wish to rotate the point.
and in 2d x and y are exactly that, your x and y coordinates.
X' and Y' are the rotated coordinates.


This function works great for rotating a point about the origin, but I need to translate the functions so that the origin is centered around my arbitrary point, like dwarsoft said.

I guess my porblem is how do I do this.. I spent all night last night reading through all of my old calc books on shifting a function but that doesn't seem to work.

SteveMiester, ^_^ I would be doing everything in java2d and java3d, except I would like everything to be cross compatible. Besides that I think it would really help if I had an understanding of these functions.

Any help would be much appreciated!

War doesn't determine who is right, war determines who is left.

Edited by - Wrathnut on August 29, 2000 2:45:26 PM
0

Share this post


Link to post
Share on other sites
Its actually pretty simple, and you''ll probably kick yourself when you see the solution for not realizing it earlier.

You have a point (x1, y1) that you want to rotate by angle theta around another point (x2, y2).

First translate both points by (-x2,-y2). This places your rotational axis point at (0,0), but keeps the relative locations the same.

Now do the rotation as you stated:

x1'' = x1*cos(theta) - y1*sin(theta)
y1'' = x1*sin(theta) + y1*cos(theta)

Now translate both points by (x2, y2). The rotational axis point is back where it started, and the point you wanted to rotate is now rotated.

Of course, if you think about it, you really only need to translate & reverse translate the first point (x1,y1), and not both of them since translating the rotational axis point will always give you (0,0). This whole thing can be simplified down to

x1'' = ( (x1-x2)*cos(theta) - (y1-y2)*sin(theta) ) + x2
y1'' = ( (x1-x2)*sin(theta) + (y1-y2)*cos(theta) ) + y2
x1 = x1''
y1 = y1''

Of course should ideally optimize this so that you do less calculations (especially the sin and cos).
0

Share this post


Link to post
Share on other sites
^_^, hehe you are right Lord Kronos, I should kick myself. Thanks alot for your insight though. I tried the could and it works great! Thanks again for eveyones help, you guys are the best.

War doesn't determine who is right, war determines who is left.
0

Share this post


Link to post
Share on other sites