Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-30 Thread Slavomir Kaslev
On 11/29/06, Krasimir Angelov [EMAIL PROTECTED] wrote: It is possible of course but your definition doesn't correspond to any operation in the usual vector algebra. By the way how do you define (*)? Isn't it 3D vector multiplication? (*) is per component multiplication, as it is in Cg/HLSL.

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Krasimir Angelov
Hi Slavomir, On 11/28/06, Slavomir Kaslev [EMAIL PROTECTED] 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

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Henning Thielemann
On Tue, 28 Nov 2006, Brian Hulley wrote: While it may be tempting to want to use symbolic operators like + and -, these quickly become very confusing when more distinctions need to be made (eg between cross product, dot product, and scaling, or between transforming a position versus

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Slavomir Kaslev
On 11/29/06, Krasimir Angelov [EMAIL PROTECTED] wrote: Hi Slavomir, On 11/28/06, Slavomir Kaslev [EMAIL PROTECTED] wrote: instance Num Float3 where . signum a | a == Float3 0 0 0 = 0 | otherwise = 1 signum has a natural generalization for vectors. signum v =

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-29 Thread Krasimir Angelov
It is possible of course but your definition doesn't correspond to any operation in the usual vector algebra. By the way how do you define (*)? Isn't it 3D vector multiplication? Krasimir On 11/29/06, Slavomir Kaslev [EMAIL PROTECTED] wrote: You mean signum = normalize? What do you think of my

[Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Slavomir Kaslev
Hello, I have to define a couple of float2, float3, float4 Cg, HLSL style vectors in Haskell. At first I was tempted to make them instances of Num, Floating, RealFrac, etc. but some of the functions defined in those classes have no sense for vectors. One such example is signum from class Num.

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Bulat Ziganshin
Hello Slavomir, Tuesday, November 28, 2006, 3:46:13 PM, you wrote: Last question: Does haskell have something like C++ templates? For example, some time in the future I may need types like int2, short3, etc., that behave just like float2, float3, but use different types for their components.

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Slavomir Kaslev
On 11/28/06, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Slavomir, Tuesday, November 28, 2006, 3:46:13 PM, you wrote: Last question: Does haskell have something like C++ templates? For example, some time in the future I may need types like int2, short3, etc., that behave just like

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Slavomir Kaslev
On 11/28/06, Slavomir Kaslev [EMAIL PROTECTED] wrote: On 11/28/06, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Slavomir, Tuesday, November 28, 2006, 3:46:13 PM, you wrote: Last question: Does haskell have something like C++ templates? For example, some time in the future I may need

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Robert Dockins
On Nov 28, 2006, at 7:46 AM, Slavomir Kaslev wrote: Hello, I have to define a couple of float2, float3, float4 Cg, HLSL style vectors in Haskell. At first I was tempted to make them instances of Num, Floating, RealFrac, etc. but some of the functions defined in those classes have no sense for

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Brian Hulley
Slavomir Kaslev wrote: I have to define a couple of float2, float3, float4 Cg, HLSL style vectors in Haskell. At first I was tempted to make them instances of Num, Floating, RealFrac, etc. but some of the functions defined in those classes have no sense for vectors. I'd suggest that this

Re: [Haskell-cafe] [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-11-28 Thread Slavomir Kaslev
On 11/28/06, Brian Hulley [EMAIL PROTECTED] wrote: Slavomir Kaslev wrote: I have to define a couple of float2, float3, float4 Cg, HLSL style vectors in Haskell. At first I was tempted to make them instances of Num, Floating, RealFrac, etc. but some of the functions defined in those classes