Skip to content

on vector constructors

Boris Batkin edited this page Jan 11, 2019 · 3 revisions

typical vector type has

  • basic constructor, for example float2() which will initialize all fields to zero
  • single value constructor, for example float4(13) which will initialize all fields to that one value
  • full blown constructor, for example float3(x,y,z) which will initialize individual fields

all vector constructors are expect to have all arguments to be of the same type

  • float2(0x12,0x13) - fine
  • float3(1,2,3.0) - error, the last field is not an integer

all vector constructors will accept all numeric types

  • range(1.2,2.3) will perform normal type conversion, and will end up being range(1,2)

Q> how are constructors different from the regular functions?
A> they are not

Clone this wiki locally