9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@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	[thread overview]
Message-ID: <26CBEB2B018684C137675D9A0C6AD08A@eigenstate.org> (raw)
In-Reply-To: <A78EA9B15B57033D2D46121A23042EC4@antares-labs.eu>

> 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.



      parent reply	other threads:[~2020-02-18 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-16 18:43 rgl
2020-02-16 19:34 ` [9front] " Eli Cohen
2020-02-16 20:01   ` rgl
2020-02-16 19:59 ` Steve Simon
2020-02-16 20:05   ` rgl
2020-02-17 23:33 ` cinap_lenrek
2020-02-18 14:43 ` ori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26CBEB2B018684C137675D9A0C6AD08A@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    --cc=rgl@antares-labs.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).