Cartesian and polar coordinates library

ruby

    Next

  • 1. ruby-debug-ide & Vim
    Hi, There is a vim-ruby-debugger script out there. It seems to work fine. However when starting sup within the debugger using this command: rdebug-ide -Ilib -p 39767 -- bin/sup There is an exception: Uncaught exception: Could not find RubyGem xapian-full (>= 1.1.3.1) This command runs fine: ruby -Ilib bin/sup So doesn't rdebug-ide support either GEM_PATH or RUBYOTP=rubygems option? Marc Weber

Cartesian and polar coordinates library

Postby Bart Braem » Thu, 24 Aug 2006 17:37:45 GMT

Hello,

For a personal project I had to create a library of cartesian and polar
coordinates. Is anyone else interested in this code? If so I'll try to turn
it in to a library and release it on rubyforge.
Just my way of saying thanks for Ruby, this turns out to be a really nice
language!

Regards,
Bart

Re: Cartesian and polar coordinates library

Postby Piers Harding » Thu, 24 Aug 2006 19:06:30 GMT

Hi - 

"It's easier to ask for forgiveness than it is to ask for permission"
... so, if I were you I'd just do it :-).

Cheers.






-- 
Home -  http://www.**--****.com/ 
xmpp: XXXX@XXXXX.COM 


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFE7CiiGETamPT/o4ARAixUAJ9wscdv8ZucdTJS1h/E2Iakd1Q2LgCfVDoA
IcdR4/h9unzEKLtiIW1y1s0=
=Fi5L
-----END PGP SIGNATURE-----


Re: Cartesian and polar coordinates library

Postby William Crawford » Thu, 24 Aug 2006 19:57:47 GMT



Indeed, this is so true.  In this case, the usefulness can't necessarily 
be determined by those who see this notice right now, but by those who 
find it later on rubyforge and thank you for it.

-- 
Posted via  http://www.**--****.com/ 


Re: Cartesian and polar coordinates library

Postby Bart Braem » Thu, 24 Aug 2006 22:14:57 GMT






You are probably right there. I'll throw it on rubyforge when I have
transformed the code into a library.

Bart

Re: Cartesian and polar coordinates library

Postby ara.t.howard » Thu, 24 Aug 2006 23:25:48 GMT






i could use it today!

-a
-- 
to foster inner awareness, introspection, and reasoning is more efficient than
meditation and prayer.
- h.h. the 14th dali lama


Re: Cartesian and polar coordinates library

Postby Kenosis » Fri, 25 Aug 2006 03:59:33 GMT






And if you don't want to go to the trouble of a rubyforge, just post it
on the Ruby RAA.

Ken


Similar Threads:

1.cartesian product of arrays

Hello,

did I miss some standard library function? Anyway, then I'll do it on
my own:

def cartprod(*args)
  result = [[]]
  while [] != args
    t, result = result, []
    b, *args = args
    t.each do |a|
      b.each do |n|
        result << a + [n]
      end
    end
  end
  result
end

Example:
cartprod([1,2],[3,4,5],[6,7,8])
=> [[1, 3, 6], [1, 3, 7], [1, 3, 8], [1, 4, 6], [1, 4, 7], [1, 4, 8],
    [1, 5, 6], [1, 5, 7], [1, 5, 8], [2, 3, 6], [2, 3, 7], [2, 3, 8],
    [2, 4, 6], [2, 4, 7], [2, 4, 8], [2, 5, 6], [2, 5, 7], [2, 5, 8]]

Regards
  Thomas

2.cartesian product - next to last version

Hello,

Since the original thread got a little long, I decided to post my next to 
last version in a new thread. My previous version gave results like 
[[1,4],7] for more than two arrays when you really wanted [1,4,7]. The trick 
is to flatten each element of the product. The following works for any 
number of arrays. Of course you might want a product in which the elements 
of that product are arrays. Any suggestions?

class Array

  def cartprod(b=[])
    if b.empty? then
      #assume self an array of arrays
      inject {|cp,x| cp.cartprod(x) }
    else
      z = inject([]) {|a,x| b.inject(a) {|a,y| a << [x,y]}}
      z.collect! {|x| x.flatten }
    end
  end

end


a=[1,2,3]
b=[4,5,6]
c=[7,8,9]

# works fine
p [a,b,c].cartprod

# doesn't work since [1,4,7,[10,11]] is [1,4,7,10,11]
d=[10, [11,12]]
p [a,b,c,d].cartprod


3.cartesian product

Hello,

How would I create a function that will take list (array) of integers and 
return their cartesian product?

Thank You,

Walter Kehowski
nuby 


4.Ruby Tk and X/Y coordinates

5.Ruby/Tk (X,Y) Coordinate Question

6. ruby graph: coordinate plane?

7. Mark GPS coordinates on image file

8. mouse coordinates in a gnome2 canvas



Return to ruby

 

Who is online

Users browsing this forum: No registered users and 51 guest