0

Quick newbie question: how do I read the block of code below (it comes from the textbook Physically Based Rendering Section 12.1)? It's something that I've never seen before. Is it the prototype for three different functions of class Light (i.e. Light::nSamples, Light::LightToWorld, and Light::WorldToLight)?

(Light Interface) ≡                                                                                  606
Light(const Transform &l2w, int ns = 1)
    : nSamples(max(1, ns)), LightToWorld(l2w),
       WorldToLight(Inverse(l2w)) {
     (Warn if light has transformation with scale)
}
  • That's not valid C++ code. That said, I guess you are confused about the syntax on an initialisation list. Please read a C++ tutorial, it's explained there. – Ulrich Eckhardt Mar 13 '16 at 19:08
  • It comes from a textbook; so I figure they mean to use psuedocode. I I assume that they are defining this category _Light Interface_ to be composed of three different functions: nSamples, LightToWorld, and WorldToLight. –  Mar 13 '16 at 19:16
  • Those are not functions, but member variables or base classes, instantiated at construction time. – xvan Mar 13 '16 at 19:19
  • The syntax of pseudocode is meaningless because it doesn't have to be compiled. And no, your assumption is probably wrong. Did you make that assumption before or after reading a C++ tutorial or researching the term I gave you? – Ulrich Eckhardt Mar 14 '16 at 06:25

2 Answers2

1

You have a bunch of pseudo code mixed with c++ syntax.

(Light Interface) ≡

It means nothing, probably a comment. You even have some Unicode chars there.

The rest looks like a bad definition of a constructor of class Light

Light(const Transform &l2w, int ns = 1)

This would be the constructor with it's arguments, it's has an error as it should be Light::Light(const Transform &l2w, int ns = 1)

    : nSamples(max(1, ns)), LightToWorld(l2w),
       WorldToLight(Inverse(l2w))

This is instantiation of member variables and base classes.

{
     (Warn if light has transformation with scale)
}

Here would go the constructor code, instead of another weird pseudocode comment.

xvan
  • 4,554
  • 1
  • 22
  • 37
  • Just so I know, why is it bad to have Unicode characters in a C++ statement? –  Mar 13 '16 at 19:31
0

There's a good reason you've never seen it before. This is nonsense:

(Light Interface) =

The rest, if it was written

Light::Light(const Transform & l2w, int ns - 1)
...

would be the definition of a constructor.

I'm not familiar with the book this comes from, but I'm skeptical that this sort of informality will actually be helpful.

Pete Becker
  • 74,985
  • 8
  • 76
  • 165
  • In my mind it's just psuedocode. I think it means. "(Light Interface) ≡ " means that the catetory _Light Interface_ is defined to be... and the rest of it would just be a constructor. –  Mar 13 '16 at 19:20