Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th May 2013, 10:33   #1  |  Link
Yeah_oh
Registered User
 
Join Date: Jan 2013
Posts: 3
How to make an image rotates about its own axis?

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
Yeah_oh is offline   Reply With Quote
Old 6th May 2013, 13:52   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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.ph...59#post1602759

If you really mean rotate like earth (spinning globe), then you would need a series of images (or clip) and not just one.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 6th May 2013 at 15:37.
StainlessS is offline   Reply With Quote
Old 6th May 2013, 17:07   #3  |  Link
Yeah_oh
Registered User
 
Join Date: Jan 2013
Posts: 3
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.
Yeah_oh is offline   Reply With Quote
Old 6th May 2013, 17:31   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by Yeah_oh View Post
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?




Quote:
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 ?

Last edited by poisondeathray; 6th May 2013 at 17:40.
poisondeathray is offline   Reply With Quote
Old 6th May 2013, 18:19   #5  |  Link
Yeah_oh
Registered User
 
Join Date: Jan 2013
Posts: 3
Quote:
Originally Posted by poisondeathray View Post
Do you mean a 2d image rotate on the Y-axis ?

sort of like this?


Thanks god! That's exactly what I want! Can you tell me how to do that
Yeah_oh is offline   Reply With Quote
Old 6th May 2013, 19:24   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by Yeah_oh View Post
Thanks god! That's exactly what I want! Can you tell me how to do that
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

Last edited by poisondeathray; 6th May 2013 at 19:49.
poisondeathray is offline   Reply With Quote
Old 6th May 2013, 23:04   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I'm sure somebody could do better than this, but first time I've used quad.

Code:
#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
Code:
#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
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 6th May 2013 at 23:40.
StainlessS is offline   Reply With Quote
Old 6th May 2013, 23:41   #8  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
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 ?
poisondeathray is offline   Reply With Quote
Old 6th May 2013, 23:49   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 6th May 2013 at 23:53.
StainlessS is offline   Reply With Quote
Old 7th May 2013, 00:16   #10  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by StainlessS View Post
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
poisondeathray is offline   Reply With Quote
Old 7th May 2013, 00:49   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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?

Code:
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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th May 2013 at 10:28.
StainlessS is offline   Reply With Quote
Old 7th May 2013, 10:54   #12  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
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
wonkey_monkey is offline   Reply With Quote
Old 7th May 2013, 18:22   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th May 2013 at 19:17.
StainlessS is offline   Reply With Quote
Old 8th May 2013, 00:31   #14  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
For a correct perspective view, I believe the coordinates t1x (etc) in the script should be set as follows:
Code:
    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.

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.
__________________
GScript and GRunT - complex Avisynth scripting made easier

Last edited by Gavino; 8th May 2013 at 08:47.
Gavino is offline   Reply With Quote
Old 8th May 2013, 09:55   #15  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
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).
wonkey_monkey is offline   Reply With Quote
Old 8th May 2013, 11:46   #16  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by davidhorman View Post
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.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 8th May 2013, 12:19   #17  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
Oh yeah, that's what I meant!
wonkey_monkey is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:30.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.