From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mimir.eigenstate.org ([206.124.132.107]) by ewsd; Tue Feb 18 09:43:34 EST 2020 Received: from abbatoir.fios-router.home (pool-162-83-132-245.nycmny.fios.verizon.net [162.83.132.245]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 7a75051e (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO); Tue, 18 Feb 2020 06:43:19 -0800 (PST) Message-ID: <26CBEB2B018684C137675D9A0C6AD08A@eigenstate.org> To: rgl@antares-labs.eu, 9front@9front.org Subject: Re: [9front] rotate: perform arbitrary rotations Date: Tue, 18 Feb 2020 06:43:18 -0800 From: ori@eigenstate.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: full-stack component descriptor scripting-oriented database > hi all, > > would it be OK to commit this? > > > -rodri > > +Memimage* > +rotate(Memimage *m, double θ) > +{ > + Memimage *w; > + Rectangle r; > + Point p, c; > + > + if((w = allocmemimage(m->r, m->chan)) == nil) > + sysfatal("allocmemimage: %r"); > + memfillcolor(w, DTransparent); > + c = divpt(addpt(m->r.min, m->r.max), 2); > + for(r = m->r; r.min.y < m->r.max.y; r.min.y++){ > + r.min.x = m->r.min.x; > + r.max.y = r.min.y+1; > + for(; r.min.x < m->r.max.x; r.min.x++){ > + r.max.x = r.min.x+1; > + p = rotatept(r.min, θ, c); > + if(ptinrect(p, m->r)) > + memimagedraw(w, r, m, p, nil, ZP, S); > + } > + } > + freememimage(m); > + return w; > +} This is probably not going to give very good results, since you're not doing any filtering. There are good algorithms for doing affine transformations. It's probably worth doing that.