My Guest Post on the VC Team blog

I answered a public invitation by Eric Battalio of the VC team – and just now published an article on the VC blog, introducing the native Expression Evaluator:

Every time you use the Watch window, a lot is going on behind the scenes. Whenever you type a variable name, something needs to map that name to the memory address and type of the named variable, then display that variable, properly formatted based on its type. Conversely, when you modify the contents of a variable – something needs to take your text input, convert it to the right type and correctly update the memory at the right address.

That something is the Expression Evaluator. It is an impressive and often overlooked piece of technology and once familiar with it, you can put it to good use, sometimes in surprising ways!

Check it out!

Geometric Inverse Application 1: Barycentric Coordinates

Last time I jotted down some equations suggesting how you should understand 3d matrix inverses, or how to solve 3×3 equations. Below is a first application, for obtaining barycentric coordinates.

Barycentric coordinates are the canonical way of describing a point within a triangle (or more generally, within a polygon, or just any convex point set). Briefly put, suppose you’re given a triangle with vertices A, B & C, and an interim point P:

P’s position relative to A, B and C can be described by a set of 3 scalars, say α, β & γ, called its barycentric coordinates:

For P to lie in the plane formed by A, B & C these ingredients must satisfy –

And for P to lie within the triangle, they must satisfy –

You can think of these equations as describing a recipe for cooking up P from the ingredients A, B & C: α as the amount of A you need to put in, β the amount of B γ of C. These coordinates are very useful, for example, for interpolation: quantities that are stored for A, B & C can be mixed with the same coefficients and applied to P.

Now how do you actually find barycentric coordinates? Well, the equation defining them can be rewritten in matrix form:

Which gives a still-not-very-explicit expression for the coordinates:

The derivation in the previous post gives a way to deduce expressions for each coordinate. Say, for α:

And similarly:

For some extra geometric flavour, note that these quotients can be understood as ratios of areas: α is the ratio of the area of the triangle P-B-C to the area of the full triangle A-B-C:

Finally, a correction of an apparently common misconception. I’ve heard a few times the interpretation of barycentric coordinates as a expressing distances of some sort – it is indeed tempting to think that if α is close to 1 then P’s distance from A is small. That just isn’t true. For example in this setup –

A is the triangle vertex closest to P, and still the α coordinate is zero – as low as it can get. When ‘cooking up’ P, we have to mix in only B and C – with no A at all.

Windows Internals Course by Sela College

A word just for Israeli readers:

Sela College has agreed to open a Windows Internals Class in Ramat-Gan. It’s a 5 day course, every Sunday starting June 24.

It’s obviously based on the identically named book, and the syllabus is as in-depth as you can possibly get in a course. Planned instructor is internals veteran Noam Sheffer.

I consider this course a rare opportunity (no, really, next one is in 1.5Y if at all) for an assisted dive into some really deep water. I’m going, so are 6 of my colleagues, and if you’re interested – I recommend you join. Either online or otherwise.

Disclaimer: It was my request that started it and so I feel somewhat responsible and am trying to help spread the word. I’ve no affiliation whatsoever with Sela or any of their employees, and am genuinely thrilled about this course.