Log in

View Full Version : How to make an image rotates about its own axis?


Yeah_oh
6th May 2013, 10:33
Hello!
I have an image and a clip. I overlay the image on the clip, but the image only stand still, I want to make it rotates about its own axis (like earth), rotates in and out also. But I don't know how to do it. Please help me!
Sorry for my bad English :(

StainlessS
6th May 2013, 13:52
Not sure if this is what you want but look here (quad - quadrilateral transform):-
http://forum.doom9.org/showthread.php?t=165978

And to see what it can do, a small ~1.4MB MP4 clip @ this post in same thread:-
http://forum.doom9.org/showthread.php?p=1602759#post1602759

If you really mean rotate like earth (spinning globe), then you would need a series of images (or clip) and not just one.

Yeah_oh
6th May 2013, 17:07
I don't know how to explain. I want the image appears in 30 frames. Use a straight that go through center of the image from top to bottom as an axis. And the image rotates around this axis (10 frames), stand still (10 frames), then rotates again (10 frames) and disappears.

poisondeathray
6th May 2013, 17:31
I don't know how to explain. I want the image appears in 30 frames. Use a straight that go through center of the image from top to bottom as an axis. And the image rotates around this axis (10 frames), stand still (10 frames), then rotates again (10 frames) and disappears.

Do you mean a 2d image rotate on the Y-axis ?

sort of like this?

http://i39.tinypic.com/34jd5py.gif



I want to make it rotates about its own axis (like earth), rotates in and out also.


or did you mean orbital rotation as well? both rotation around it's own Y axis, and rotation around another object (sun)

or can you find a video (maybe youtube) that describes what you want to do ?

Yeah_oh
6th May 2013, 18:19
Do you mean a 2d image rotate on the Y-axis ?

sort of like this?

http://i39.tinypic.com/34jd5py.gif



Thanks god! That's exactly what I want! Can you tell me how to do that :thanks:

poisondeathray
6th May 2013, 19:24
Thanks god! That's exactly what I want! Can you tell me how to do that :thanks:

I did this in another program (after effects, and it's just a simple rotation in the Y-axis) , but it should be possible with possibly quad or one of vcmohan's plugins . I'm sure someone will suggest how to do this in avisynth if you wait a bit

Alternatively you could use an image editor like gimp to save out an image sequence that rotates the layer
http://registry.gimp.org/node/25104

Or maybe blender

EDIT: another free one that can do this is debugmode wax

StainlessS
6th May 2013, 23:04
I'm sure somebody could do better than this, but first time I've used quad.


#ImageSource("D:\avs\a.png").ConvertToRGB32()
ColorBars()
PI2=PI*2.0
CYCLE = 30
V = 0.2 # Tilt
tim = PI2 / CYCLE
ScriptClip("""
c=last
t=tim*current_frame
t1x= 0.5 - 0.5 * cos(t) # BOTH Left
t2x= 0.5 + 0.5 * cos(t) # BOTH Right
#
t1y= 0.0 - V * sin(t) # ] both Top's opposite sign
t2y= 0.0 + V * sin(t) # ]
t3y= 1.0 + V * sin(t) # [ both Bottoms opposite sign
t4y= 1.0 - V * sin(t) # [
quad(t1x,t1y, t2x,t2y, t2x,t3y, t1x,t4y, normal=true)
""")
Return Last


EDIT: or maybe this a bit better

#ImageSource("D:\avs\a.png").ConvertToRGB32()
ColorBars()
PI2=PI*2.0
CYCLE = 30
V = 0.2 # Tilt
tim = PI2 / CYCLE
ScriptClip("""
c=last
t=tim*current_frame
t1x= 0.5 - 0.5 * cos(t) # BOTH Left
t2x= 0.5 + 0.5 * cos(t) # BOTH Right
#
t1y= 0.0 + V * sin(t) # ] both Top's opposite sign
t2y= 0.0 - V * sin(t) # ]
t3y= 1.0 + V * sin(t) # [ both Bottoms opposite sign
t4y= 1.0 - V * sin(t) # [
quad(t1x,t1y, t2x,t2y, t2x,t3y, t1x,t4y, normal=true)
""")
Return Last

poisondeathray
6th May 2013, 23:41
2nd one works well - nice job Stainless :)

But does it seem to be rotating around a "thick" axis ? or is it my mind playing tricks ?

StainlessS
6th May 2013, 23:49
Yep, it dont seem quite right but I dont see any problem in coords.
Perhaps David will pop along presently.

EDIT: Might just be an optical illusion.

poisondeathray
7th May 2013, 00:16
Yep, it dont seem quite right but I dont see any problem in coords.
Perhaps David will pop along presently.

EDIT: Might just be an optical illusion.

Just an impression that there seems to be a movement in z-depth , as if it's rotating around a cylinder ?

I tried to line this example up to your 2nd script for comparison purposes (lagarith RGB, 3MB), as an example of pure Y-axis rotation
http://www.mediafire.com/?n0vmur3s6qdbvmm

(and here is the test image used)
http://www.mediafire.com/view/?4z2g19oqs9mss4n

StainlessS
7th May 2013, 00:49
You are correct, definite cylindrical roll involved. Although I'm not sure that I'm using current version, used the non SSE version.
Think maybe Mr Horman might like to comment on this.

By the way, nice pic, did you paint it yourself?


ImageSource("D:\avs\Mona_00.png").ConvertToRGB32()
#ImageSource("D:\avs\a.png").ConvertToRGB32()
#ColorBars()
HALFCYCLE=10 # Frames in 1 HALF rotation (spinning clip)
NSPIN = 1 # Number of HALF rotations in spinning clip
NSTILL = 10 # Frames in STILL clip
V = 0.2 # Tilt/Yaw
tim = PI / HALFCYCLE
ScriptClip("""
c=last
t=tim*current_frame
t1x= 0.5 - 0.5 * cos(t) # BOTH Left
t2x= 0.5 + 0.5 * cos(t) # BOTH Right
#
t1y= 0.0 + V * sin(t) # ] both Top's opposite sign
t2y= 0.0 - V * sin(t) # ]
t3y= 1.0 + V * sin(t) # [ both Bottoms opposite sign
t4y= 1.0 - V * sin(t) # [
quad(t1x,t1y, t2x,t2y, t2x,t3y, t1x,t4y, normal=true)
""")

SPIN=Trim(0,-(NSPIN*HALFCYCLE +1)) # Spinning clip, + 1 to complete last spin
STILL=SPIN.Trim(SPIN.FrameCount-1,-1).Loop(NSTILL,0,0)
SPIN2=Trim((NSPIN%2 ==0)?0:HALFCYCLE,-(NSPIN*HALFCYCLE +1))
SPIN ++ STILL ++ SPIN2
Return Last


EDIT: Modified to OP requirements, now settings in HALF spin cycles. Works pretty good.

wonkey_monkey
7th May 2013, 10:54
Briefly:

Faulty maths ;) For example, at an extreme angle, the gap from the left side of the video to the left side of the spun image is the same as on the right, but if perspective was taken into account, it shouldn't be.

I'm too busy to work it out just now, but I have a filter at home called rpntransform3d (or something like that) which would be pretty useful here.

Also to consider: some kind of varying blur to avoid aliasing (or perform at 2^n res and reduceby2 n times)

David

StainlessS
7th May 2013, 18:22
Thankyou Mr.H, thought it might be something like that. When you do get time, would love to hear a correction on supplied math, and why.
Also, thanx for the plug, most interesting.

Gavino
8th May 2013, 00:31
For a correct perspective view, I believe the coordinates t1x (etc) in the script should be set as follows:
c = cos(t)
vs = V*sin(t)

t1x = 0.5*(1 - c/(1+vs))
t2x = 0.5*(1 + c/(1-vs))
t1y = 0.5*vs/(1+vs)
t2y = -0.5*vs/(1-vs)
t3y = 1.0 - t2y
t4y = 1.0 - t1y
The constant V controls the perspective and should be such that 0 < V < 1, with larger values moving the viewpoint (or camera) closer to the screen. It corresponds roughly to double the V used in the original script, so for a similar view (but with correct perspective), a value of 0.4 should be used (where previously 0.2).

I don't have time to explain the calculations, but basically it involves treating the image as a 2D object moving in 3D space, and projected onto a screen viewed from a finite distance. At each point of the animation, you need to determine the 3D location of each corner, then project those points onto the screen, as shown here (http://en.wikipedia.org/wiki/3D_projection#Diagram).

EDIT:
StainlessS - looking again at your version, I see it actually represents an orthogonal projection (observer at infinity) of an image tilted into the screen and rotating on its axis. That's why it appears to rotate about a cylinder.

wonkey_monkey
8th May 2013, 09:55
You may need to avoid even values of HALFCYCLE as it looks like quad can go a bit mental when two or more corners of the target quadrilateral occupy the same point (I think it's something to do with a matrix ending up a with a determinant of 0, or something).

Gavino
8th May 2013, 11:46
You may need to avoid even values of HALFCYCLE as it looks like quad can go a bit mental when two or more corners of the target quadrilateral occupy the same point
The four corners always occupy different points (in both my version and StainlessS's one), but when the angle of rotation is 90 degrees, they all lie in a straight line (the central axis), which is probably equally problematic as the quadrilateral reduces to zero width.

wonkey_monkey
8th May 2013, 12:19
Oh yeah, that's what I meant! :stupid: