Discuss Scratch

hppavilion
Scratcher
100+ posts

Drawing an Angled Ellipse

What I have is this:
define Draw ellipse with radii (r1) , (r2) at x: (x) y: (y)
pen up
set [drawStep v] to [2]
go to x:((x) + (([sin v] of (1)) * (r1))) y:((y) + (([cos v] of (1)) * (r2)))
repeat until <(y position) = ((y) + (r2))>
if <touching [_edge_ v]?> then
pen up
else
pen down
end
go to x:((x) + (([sin v] of (drawStep)) * (r1))) y:((y) + (([cos v] of (drawStep)) * (r2)))
change [drawStep v] by (1)
end
go to x:((x) + (([sin v] of (drawStep)) * (r1))) y:((y) + (([cos v] of (drawStep)) * (r2)))
pen up
I'm looking for a way that I can draw these ellipses at an angle for a component of my project. Does anyone have any ideas?
deck26
Scratcher
1000+ posts

Drawing an Angled Ellipse

No one seems to be picking up this one so I'll see if I can work something out. Might take a while!
deck26
Scratcher
1000+ posts

Drawing an Angled Ellipse

http://scratch.mit.edu/projects/41638252/ is what you want. Turned out not to be too difficult, just apply a transformation to rotate your x-y coordinates as per http://en.wikipedia.org/wiki/Rotation_matrix
deck26
Scratcher
1000+ posts

Drawing an Angled Ellipse

Modified version to cope with centre of ellipse not being the origin - http://scratch.mit.edu/projects/41640002/
hppavilion
Scratcher
100+ posts

Drawing an Angled Ellipse

deck26 wrote:

Modified version to cope with centre of ellipse not being the origin - http://scratch.mit.edu/projects/41640002/
Thanks!
gtoal
Scratcher
1000+ posts

Drawing an Angled Ellipse

hppavilion wrote:

What I have is this:
define Draw ellipse with radii (r1) , (r2) at x: (x) y: (y)
pen up
set [drawStep v] to [2]
go to x:((x) + (([sin v] of (1)) * (r1))) y:((y) + (([cos v] of (1)) * (r2)))
repeat until <(y position) = ((y) + (r2))>
if <touching [_edge_ v]?> then
pen up
else
pen down
end
go to x:((x) + (([sin v] of (drawStep)) * (r1))) y:((y) + (([cos v] of (drawStep)) * (r2)))
change [drawStep v] by (1)
end
go to x:((x) + (([sin v] of (drawStep)) * (r1))) y:((y) + (([cos v] of (drawStep)) * (r2)))
pen up
I'm looking for a way that I can draw these ellipses at an angle for a component of my project. Does anyone have any ideas?

If you still want something like this - quite fast code: http://scratch.mit.edu/projects/50039326/

Powered by DjangoBB