Re: 2D vector code

2006-04-20 Thread Han-Wen Nienhuys
2006/4/14, David Feuer <[EMAIL PROTECTED]>:
> Does scm/guile not have such funtions for pairs/complex vectors?It probably does support complex numbers.  Complex numbers, however,are conceptually quite different from 2D vectors, and I don't feelcomfortable conflating them.  It's up to you and Han, of course.
I think that complex numbers  are perfect for 2D vectors. I can't imagine a situation were we would need an SCM value that can both be a complex number and a 2d offset, so I think it shouldn't be a problem, but if you're uncomfortable with identifying them, I recommend you add  a bunch of aliases, eg:
  (define vector-2d-add +) 
___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-16 Thread Johannes Schindelin
Hi,

On Sun, 16 Apr 2006, David Feuer wrote:

> As I said, I'm not going to be working on any LilyPond this month, but I 
> think the best of those is vector-2d, which has the problems of being 
> too long and too easily confused with Scheme vectors.  Whatever.

Well, maybe when you come back, there will be some real bugs to 
fix in LilyPond.

Ciao,
Dscho



___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-15 Thread David Feuer
On 4/15/06, Carl D. Sorensen <[EMAIL PROTECTED]> wrote:
> As far as Lilypond is concerned, I don't think most of them _are_ vectors.  
> The points I've used in developing stencils _have_ been points (e.g. bounding 
> box corners)  I guess in your work with ps, there may be more vector stuff.  
> I haven't followed it up closely.
>
> vec and vec2 are inconsistent with lilypond style.  Lilypond style calls for 
> using full english words, not abbreviations.  (This used to be in the 
> Standards section of the webpage, but the naming section is now blank, so 
> maybe this convention is deprecated).
>
> Perhaps 2d-vector, xy-vector, r2-vector, vector-2d, or vector-xy.

As I said, I'm not going to be working on any LilyPond this month, but
I think the best of those is vector-2d, which has the problems of
being too long and too easily confused with Scheme vectors.  Whatever.
 I haven't used vectors in the PostScript code, but I used them in the
SVG polygon code, and if I get a chance to refactor LilyPond's output
system this summer, I expect to use them much more heavily in both PS
and SVG.

David


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


RE: 2D vector code

2006-04-15 Thread Carl D. Sorensen
As far as Lilypond is concerned, I don't think most of them _are_ vectors.  The 
points I've used in developing stencils _have_ been points (e.g. bounding box 
corners)  I guess in your work with ps, there may be more vector stuff.  I 
haven't followed it up closely.
 
vec and vec2 are inconsistent with lilypond style.  Lilypond style calls for 
using full english words, not abbreviations.  (This used to be in the Standards 
section of the webpage, but the naming section is now blank, so maybe this 
convention is deprecated).
 
Perhaps 2d-vector, xy-vector, r2-vector, vector-2d, or vector-xy.
 
Carl



From: David Feuer [mailto:[EMAIL PROTECTED]
Sent: Fri 4/14/2006 5:21 PM
To: Carl D. Sorensen
Cc: Jan Nieuwenhuizen; lily-devel
Subject: Re: 2D vector code



On 4/14/06, Carl D. Sorensen <[EMAIL PROTECTED]> wrote:

>
> After reviewing what the scheme code would look like if we used complex
> numbers, and thinking about the benefits of having nice names for data
> types and procedures, I think I agree that we ought to have our own
> coordinate pair type and functions.  I couldn't find it as a supported
> function in SRFI-*.  I don't think we ought to use the term vector,
> because scheme already has a defined vector type, which is not an R2
> vector.  I'd recommend coordinate, point, or coordinate-pair.

I've started work implementing 2d vectors as SRFI-9 records.  I don't
have a great name, but I don't like point because vectors usually
don't represent points.  coordinate and coordinate-pair seem a little
vague.  How about vec or vec2?

David




___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-14 Thread David Feuer
On 4/14/06, Carl D. Sorensen <[EMAIL PROTECTED]> wrote:

>
> After reviewing what the scheme code would look like if we used complex
> numbers, and thinking about the benefits of having nice names for data
> types and procedures, I think I agree that we ought to have our own
> coordinate pair type and functions.  I couldn't find it as a supported
> function in SRFI-*.  I don't think we ought to use the term vector,
> because scheme already has a defined vector type, which is not an R2
> vector.  I'd recommend coordinate, point, or coordinate-pair.

I've started work implementing 2d vectors as SRFI-9 records.  I don't
have a great name, but I don't like point because vectors usually
don't represent points.  coordinate and coordinate-pair seem a little
vague.  How about vec or vec2?

David


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


RE: 2D vector code

2006-04-14 Thread Carl D. Sorensen
 
David Feuer wrote:
---
The complex numbers form a field.  The 2-D vectors don't.  A complex
number suggests that the real and imaginary components are of a
different nature, whereas 2-D vectors are symmetrical in their
components.  Vectors could be implemented using complex numbers, but I
think identifying them is ugly.

Carl here:

After reviewing what the scheme code would look like if we used complex
numbers, and thinking about the benefits of having nice names for data
types and procedures, I think I agree that we ought to have our own
coordinate pair type and functions.  I couldn't find it as a supported
function in SRFI-*.  I don't think we ought to use the term vector,
because scheme already has a defined vector type, which is not an R2
vector.  I'd recommend coordinate, point, or coordinate-pair.

Carl


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-14 Thread Geoff Horton
> The complex numbers form a field.  The 2-D vectors don't.  A complex
> number suggests that the real and imaginary components are of a
> different nature, whereas 2-D vectors are symmetrical in their
> components.  Vectors could be implemented using complex numbers, but I
> think identifying them is ugly.

The question is whether one is viewing things from a mathematician's
standpoint or a programmer's standpoint. To a programmer, they are
functionally equivalent, aren't they?

Geoff


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-14 Thread David Feuer
On 4/14/06, Carl D. Sorensen <[EMAIL PROTECTED]> wrote:
>
> Actually, complex numbers are nothing more than 2-D vectors, but in the
> real-imaginary plane rather than the x-y plane.  In fact, when we use
> complex numbers, we draw them in a plane indistinguishable from x-y
> (real is x, imaginary is y).  So I think that if guile has built-in
> complex numbers, we certainly ought to use them.

The complex numbers form a field.  The 2-D vectors don't.  A complex
number suggests that the real and imaginary components are of a
different nature, whereas 2-D vectors are symmetrical in their
components.  Vectors could be implemented using complex numbers, but I
think identifying them is ugly.

David


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


RE: 2D vector code

2006-04-14 Thread Carl D. Sorensen
David Feuer writes

>On 4/13/06, Jan Nieuwenhuizen <[EMAIL PROTECTED]> wrote:
>> David Feuer writes:
>
>> In C++ we have Offset, which has a number of complex_* functions.  We

>> also have complex-to-offset and use offset pairs in SCM, but I do not

>> know if we have any such functions in SCM.
>
> I don't either.
>
>> Does scm/guile not have such funtions for pairs/complex vectors?
>
> It probably does support complex numbers.  Complex numbers, however,
are conceptually quite > different from 2D vectors, and I don't feel
comfortable conflating them.  It's up to you
> and Han, of course.
>

Actually, complex numbers are nothing more than 2-D vectors, but in the
real-imaginary plane rather than the x-y plane.  In fact, when we use
complex numbers, we draw them in a plane indistinguishable from x-y
(real is x, imaginary is y).  So I think that if guile has built-in
complex numbers, we certainly ought to use them.

Carl Sorensen


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-13 Thread David Feuer
On 4/13/06, Jan Nieuwenhuizen <[EMAIL PROTECTED]> wrote:
> David Feuer writes:

> In C++ we have Offset, which has a number of complex_* functions.  We
> also have complex-to-offset and use offset pairs in SCM, but I do not
> know if we have any such functions in SCM.

I don't either.

> Does scm/guile not have such funtions for pairs/complex vectors?

It probably does support complex numbers.  Complex numbers, however,
are conceptually quite different from 2D vectors, and I don't feel
comfortable conflating them.  It's up to you and Han, of course.

David


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-13 Thread Jan Nieuwenhuizen
David Feuer writes:

> My SVG polygon code uses 2D vectors ( (x,y) pairs ) a good bit.  Does
> LilyPond already have basic functions (addition, subtraction,
> multiplication by a scalar, dot product, cross product, ...) for
> vectors I can use?

In C++ we have Offset, which has a number of complex_* functions.  We
also have complex-to-offset and use offset pairs in SCM, but I do not
know if we have any such functions in SCM.

> If not, I think I should probably write them as a separate module.

Does scm/guile not have such funtions for pairs/complex vectors?

> If I write them as a separate module, should vectors be pairs
> (convenient), or should they be SRFI 9 records (pretty)?

Jan.

-- 
Jan Nieuwenhuizen <[EMAIL PROTECTED]> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien   | http://www.lilypond.org


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: 2D vector code

2006-04-12 Thread David Feuer
I should have mentioned that I don't know yet how C++ code interacts
with SRFI 9 records, if that's feasible at all.  I'm sure C++ can
interact with native Guile records, but I'm not sure I really want to
deal with those.

David


___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel