[Haskell-cafe] [Haskell] Defining Cg,
HLSL style vectors in Haskell
kr.angelov at gmail.com
Wed Nov 29 03:18:25 EST 2006
On 11/28/06, Slavomir Kaslev <slavomir.kaslev at gmail.com> wrote:
> instance Num Float3 where
> signum a | a == Float3 0 0 0 = 0
> | otherwise = 1
signum has a natural generalization for vectors.
signum v = vector with the same direction as v but with |v| = 1
where |v| is the absolute length of v. The problematic function in Num
is abs. Ideally abs should be defined as:
abs v = |v|
but its type is Float3 -> Float while the Num class requires Float3 -> Float3.
More information about the Haskell-Cafe