ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: How can I compare picture variables in metapost?
Date: Tue, 5 May 2009 19:28:41 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LNX.2.00.0905051921130.8272@ybpnyubfg.ybpnyqbznva> (raw)
In-Reply-To: <4A00B2B0.2080008@gmx.net>

On Tue, 5 May 2009, Peter Rolf wrote:

> Taco Hoekwater schrieb:
>> Taco Hoekwater wrote:
>>> Zhichu Chen wrote:
>>>> 
>>>> Seems that I don't have too many choices. Maybe using lua to do the
>>>> math and throwing the result to metapost is faster? I think I can do
>>>> this, but I don't know how. The documents are a little limited.
>>> 
>>> For circles, probably lua calculations will be faster because the
>>> data manipulation will be a bit easier. But for non-circle paths,
>>> you are better off with a metapost solution because of lua not
>>> knowing about the actual paths.
>> 
>> linear search does seem to do that badly, here is a stub:
>> 
> Mhh... isn't it easier to just test, if the distance (centerpoint to 
> centerpoint) from the new circle
> to all already found circles is greater (or equal) than the sum of the radii?

Depends on what you mean by "does not intersect". Taco's solution only 
checks if the curves intersect or not. So, it is possible to have two 
concentric circles. If you check for distance you get circles which do not 
overlap.

Of course, in case of circles, non-overlap can also be tested 
mathmeaticically.

if |c_1 - c_2| < max(r_1, r_2) then
    |c_1 - c_2| < |r_1 - r_2|
else
    |c_1 - c_2| > r_1 + r_2
end

> Anyhow an interesting and hard problem (I guess O(n!) ? ).

I think it is O(n^3).You only have to check all combinations (which is 
O(n^2)) and do that for each point that you add add.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2009-05-05 23:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-05 12:27 Zhichu Chen
2009-05-05 12:51 ` Taco Hoekwater
2009-05-05 13:51   ` Zhichu Chen
2009-05-05 15:04     ` Taco Hoekwater
2009-05-05 15:19       ` Zhichu Chen
2009-05-05 16:06         ` Taco Hoekwater
2009-05-05 16:54           ` Taco Hoekwater
2009-05-05 21:42             ` Peter Rolf
2009-05-05 23:28               ` Aditya Mahajan [this message]
2009-05-06  1:46                 ` Zhichu Chen
2009-05-06  2:10                   ` Aditya Mahajan
2009-05-06  3:09                     ` Aditya Mahajan
2009-05-06  9:06                 ` Peter Rolf
2009-05-05 22:57         ` Aditya Mahajan

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=alpine.LNX.2.00.0905051921130.8272@ybpnyubfg.ybpnyqbznva \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /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).