Here is a start:

module Geometry

export Point, Direction, Ray

using ImmutableArrays
typealias Vec Vector3

type Point
    c::Vec
end
Point(a::Array) = Point(Vec(a))

type Direction
    v::Vec
    Direction(v) = new(unit(v))
end
Direction(a::Array) = Direction(Vec(a))

type Ray
    pos::Point
    dir::Direction
end
Ray(a::Array,b::Array) = Ray(Point(a),Direction(b))

step(a::Point,b::Number,c::Direction) = Point(a.c + b*c.v)

end

Let me know what you  guys think.


On Wednesday, October 1, 2014 10:05:51 AM UTC+10, Yakir Gagnon wrote:
>
> A Geometry package has been discussed here 
> <https://groups.google.com/d/topic/julia-dev/vZpZ8NBX_z8/discussion> and 
> here <https://groups.google.com/d/topic/julia-dev/fqwnyOojRdg/discussion> 
> (Spherical, 
> Geographic, Homogeneous coordinate systems in 1 to 4 dimensions and more).
>
> I'm in need of something significantly simpler: a Geometry module for a 
> Cartesian coordinate system in 3D with Point, Direction, and Line types. 
> Has anyone written something like that? Maybe that ambitious Geometry 
> package is further along or been announced and I missed it?
>
> Thanks a bunch!
>

Reply via email to