POV-Ray : Newsgroups : povray.off-topic : Still random : Re: FIXED! Server Time
29 Sep 2024 17:17:30 EDT (-0400)
  Re: FIXED!  
From: Orchid XP v8
Date: 8 May 2009 14:15:15
Message: <4a0476b3$1@news.povray.org>
Darren New wrote:
> Orchid XP v8 wrote:
>> Well, if you wanted to go that far you could. 
> 
> Well, now you know why people do, when it's important to be correct. :-)
> 
> Isn't it pretty trivial to do that in Haskell, tho?

Yeah, something along the lines of

   newtype Position = Position Vector2 deriving (Eq, Show, Vector, Num)
   newtype Velocity = Velocity Vector2 deriving (Eq, Show, Vector, Num)

Now just replace all occurrances of Vector2 with Position or Velocity as 
appropriate.

The only problem is that *now* you can't say

   p1 = p0 * dt v0

without sprinkling it with typecasts.

Actually, what you'd *probably* do is define

   step :: TimeStep -> Velocity -> Position
   step dt (Velocity v) = Position (dt * v)

and then have

   p1 = p0 + step dt v0

Only problem now is that you'd have to define another such function for 
acceleration - assuming you're going to have a seperate type for that.

There's probably some better way of encoding all this. (Possibly 
assosiated types, or maybe just phantom types...)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.