How to rotate a 2d moving image like a car?

hello every one i am facing problem in rotating my car's image when i press a key the car just move upwards without any rotation because velocity change.

7 comentarios

Image Analyst
Image Analyst el 26 de Nov. de 2013
Editada: Image Analyst el 26 de Nov. de 2013
How or why is the image moving? Are you repeatedly calling set(gca, 'Position')??? Why is the velocity changing? Is the speed of the car within a frame of video (and so the video image is staying put on your screen), or the speed that your image is moving across your GUI (if the image display is moving across your computer screen)? I don't know exactly what is moving - the car in the image, or the image itself. It's very confusing so can you clarify?
Muneef
Muneef el 26 de Nov. de 2013
The image of a car is moving. i am making parking mania (game).I have to rotate it when i press a key.
Muneef
Muneef el 26 de Nov. de 2013
i am changing the position of image by adding velocity outside a while loop and inside a while loop i am giving conditions for different keys..image moves according to the keys but without rotation.
Muneef
Muneef el 26 de Nov. de 2013
my image's handle is not a matrix
Walter Roberson
Walter Roberson el 26 de Nov. de 2013
I answered there before seeing this question. The answer I gave is different than the approaches here.
Muneef
Muneef el 27 de Nov. de 2013
kindly sir , tell me how to rotate it at specific angle when i used imrotate it flips my axis all to gather . can i use the xrot and yrot equations to move it?
Walter Roberson
Walter Roberson el 27 de Nov. de 2013
Use the method I indicated in your duplicate of the question: create an hgtransform. http://www.mathworks.com/help/matlab/ref/makehgtform.html

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 26 de Nov. de 2013

0 votos

The image must remain rectangular with the edges aligned with your computer screen. So to rotate a car within that image, you're going to have to use imrotate().

4 comentarios

Image Analyst
Image Analyst el 26 de Nov. de 2013
Muneef's "Answer" moved here because it was really a comment directed at me:
You are not getting it.I have a car's image from top i just wanna rotate it in 90 degree when it changes its direction from x axis to y axis (positive) and vice versa. thanks
Image Analyst
Image Analyst el 26 de Nov. de 2013
Then you need to post a screenshot. Because I looked up parking mania and it looks like you need to rotate the car. If you don't want to use imrotate(), then use transpose (done by the apostrophe operator), flipud() or fliplr() to rotate by multiples of 90 degrees.
Muneef
Muneef el 26 de Nov. de 2013
yes i just want to rotate a car like in parking mania either by imrotateor any other command but i cant able to apply it . by im rotate my whole figure flips and car did not rotate help required in code?
Muneef
Muneef el 26 de Nov. de 2013
ok i am going to apply the flipIr command did all these command work with xdata and ydata type image means i have set image like that set(car,'xdata',value,'ydata',value)

Iniciar sesión para comentar.

Más respuestas (1)

Preguntada:

el 26 de Nov. de 2013

Comentada:

el 27 de Nov. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by