lib/mageo/vector3d.rb in mageo-0.0.3 vs lib/mageo/vector3d.rb in mageo-0.0.4
- old
+ new
@@ -96,10 +96,14 @@
end
self.angle_radian(vec0, vec1) * (180.0 / Math::PI)
end
+ def self.midpoint(vec1, vec2)
+ (vec1.to_v3d + vec2.to_v3d)/2.0
+ end
+
# Instance methods
def [](index)
raise RangeError, "index: #{index}." if (index < 0 || 2 < index)
super index
@@ -233,7 +237,11 @@
# self.rotate_axis(1, 0.5*PI)
def rotate_axis(axis, radian)
tmp = Marshal.load(Marshal.dump(self))
tmp.rotate_axis!(axis, radian)
tmp
+ end
+
+ def midpoint(other)
+ self.class.midpoint(self, other)
end
end