With apologies, this is essentially the same question as I attempted to frame in Refactoring technique?, but I finally think I've got enough of a handle on the problem to ask the right question; but not yet the solution.

(Please excuse (or ignore) the presence of JavaScript code in the following; the question pertains to all languages, and I'm bored with mocking up Perl substitutes.)

In the code I'm refactoring I've (mechanically) abstracted out three recurrent conditions, without (previously) understanding what it was they really tested:

var condX = ( ( this.Parent.Fi < 90 ) || ( this.Parent.Fi >= 270 ) + ); var condY = ( this.Parent.Fi >= 180 ); var condZ = ( this.Parent.Th <= 0 );

Obviously, condX, condY & condZ are not great names. I've finally worked out what it is that they control. (For those coming to this fresh, the code constructs 3 reference grids around a graph (chart) that is rotatable in all 3 dimensions.)

  1. condX determines whether the front or back face of the bounding box is drawn depending upon the current rotation.
  2. condY determines whether the left or right face of the bounding box is drawn depending upon the current rotation.
  3. condZ determines whether the top or bottom face of the bounding box is drawn depending upon the current rotation.

First off; those names were my "best guess" before I'd tied them down, and are not right.

But they demonstrate the real problem: All our words for ordinals/directions/etc. are tied to a point of view and our expectations

And ditto for terms like X-axis/horizontal and Y-axis/vertical, etc.

But when things can be rotated in all dimensions, left can become right; up, down; back, front, min, max; so naming things in code that can be called with stuff in any state of rotation becomes a nightmare.

Often, you can get around this problem by naming variables in terms of the model view: that is, pretending you are standing on the 'floor' of the bounding box and rotate with it (without gravity messing things up) and name them in terms relative to that viewpoint.

But equally often, and as is the case of the conditionals above, the ordinates being represented are relative to the viewer's perspective; ie. world coordinates. That is, the decision of what faces to draw is determined in terms of which faces are 'behind' the model, thus not obscuring the model (graph) from the viewer.

And that I think is the key. Whatever the orientation, the faces to be draw are the three of the six that are 'furthest' from the viewer; but even with that insight, I'm still stuck for how to name them. And as each of those conditions is reused 4 times each, I think they definitely do need to be named.

So to the question: what would you name them?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
div

In reply to Naming ordinals (directions/sides/faces) in the presence of 3D rotation? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.