1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) r46780: [Backport #9499]

* lib/matrix.rb: Fix sign for cross_product [#9499]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2014-07-11 14:08:51 +00:00
parent 068a7dff12
commit feea0a9e82
4 changed files with 15 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Fri Jul 11 23:07:09 2014 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix.rb: Fix sign for cross_product [#9499]
Sun Jul 6 23:16:30 2014 Masaya Tarui <tarui@ruby-lang.org>
* st.c (st_foreach_check): change start point of search at check

View file

@ -1764,9 +1764,9 @@ class Vector
#
def cross_product(v)
Vector.Raise ErrDimensionMismatch unless size == v.size && v.size == 3
Vector[ v[1]*@elements[2] - v[2]*@elements[1],
v[2]*@elements[0] - v[0]*@elements[2],
v[0]*@elements[1] - v[1]*@elements[0] ]
Vector[ v[2]*@elements[1] - v[1]*@elements[2],
v[0]*@elements[2] - v[2]*@elements[0],
v[1]*@elements[0] - v[0]*@elements[1] ]
end
#

View file

@ -146,4 +146,9 @@ class TestVector < Test::Unit::TestCase
v = Vector[Rational(1,2), 0]
assert_equal(0.5, v.norm)
end
def test_cross_product
v = Vector[1, 0, 0].cross_product Vector[0, 1, 0]
assert_equal(Vector[0, 0, 1], v)
end
end

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-07-06"
#define RUBY_PATCHLEVEL 168
#define RUBY_RELEASE_DATE "2014-07-11"
#define RUBY_PATCHLEVEL 169
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 7
#define RUBY_RELEASE_DAY 6
#define RUBY_RELEASE_DAY 11
#include "ruby/version.h"