Discuss Scratch

lovetocode999
Scratcher
20 posts

Geometric Transformations With Sprites

This project uses the available blocks in Scratch and combines them with math to apply
3 different geometrical transformations to the sprites using the scripts below.
  • define Translation by \{ (x) (y) \}
    change x by (x)
    change y by (y)
  • define Rotation about \{ (x) (y) \} by \{ (degress) °\}
    set [x v] to (x position)
    set [y v] to (y position)
    Point towards (x) (y) :: custom
    set [i v] to ([sqrt v] of ((((x position) - (x)) * ((x position) - (x))) + (((y position) - (y)) * ((y position) - (y)))))
    go to x: (x) y: (y)
    Point towards (x) (y) :: custom
    turn ccw (degress) degrees
    move (i) steps
  • define Dilation of scale \{ (scale) \} about \{ (x) (y) \}
    set size to ((size) * (scale)) %
    set [x v] to (x position)
    set [y v] to (y position)
    set [i v] to ([sqrt v] of ((((x position) - (x)) * ((x position) - (x))) + (((y position) - (y)) * ((y position) - (y)))))
    go to x: (x) y: (y)
    Point towards (x) (y) :: custom
    set [i v] to ((i) * (scale))
    move (i) steps
    point in direction (90 v)
To view the project, go to https://scratch.mit.edu/projects/166360836/#player
Here are some examples of how this can be used:
Orbiter Example
Mouse Orbiter Example
Sprite Warp Example
Sprite Warp 2 Example

Last edited by lovetocode999 (June 23, 2017 20:12:15)


when <(x position)=(y position)> :: events :: hat // MuHaHaHaHA!!! I am the nonexistent block monster!!!
say [I didn't know that block existed!] until <(x position :: control)<(y position :: control)> :: motion
retort [We don't exactly exixt either :|] for [5] min. and if <these blocks exist :: operators > {
say[Help! I'm with a bunch of nonexistent blocks and I'm being eaten!]
}:: control
Click Me
lovetocode999
Scratcher
20 posts

Geometric Transformations With Sprites

Bump!

when <(x position)=(y position)> :: events :: hat // MuHaHaHaHA!!! I am the nonexistent block monster!!!
say [I didn't know that block existed!] until <(x position :: control)<(y position :: control)> :: motion
retort [We don't exactly exixt either :|] for [5] min. and if <these blocks exist :: operators > {
say[Help! I'm with a bunch of nonexistent blocks and I'm being eaten!]
}:: control
Click Me
lovetocode999
Scratcher
20 posts

Geometric Transformations With Sprites

Bump!

when <(x position)=(y position)> :: events :: hat // MuHaHaHaHA!!! I am the nonexistent block monster!!!
say [I didn't know that block existed!] until <(x position :: control)<(y position :: control)> :: motion
retort [We don't exactly exixt either :|] for [5] min. and if <these blocks exist :: operators > {
say[Help! I'm with a bunch of nonexistent blocks and I'm being eaten!]
}:: control
Click Me

Powered by DjangoBB