Achieving Software Engineering Goals: Understanding AI's Frame of Reference in Code Generation

In the rapidly evolving landscape of AI-assisted development, tools like GitHub Copilot are becoming indispensable for achieving our software engineering goals. However, as developers integrate AI more deeply into their workflows, subtle differences in how AI interprets instructions compared to human intuition can emerge. A recent discussion on GitHub Community, initiated by user BugsFreed, highlights one such intriguing challenge: the "frame-of-reference ambiguity" in geometric transformations.

A developer and an AI assistant interpreting a rotated rectangle's 'bottom-left' differently, illustrating frame-of-reference ambiguity.
A developer and an AI assistant interpreting a rotated rectangle's 'bottom-left' differently, illustrating frame-of-reference ambiguity.

The AI's "Worldview": A Case of Misaligned Geometry

BugsFreed, using Visual Studio 2022 with GitHub Copilot (powered by Claude Sonnet 4.5 in agent mode), encountered a peculiar issue while instructing the AI to perform a simple graphic task. The task involved drawing a rectangle, rotating it, and then drawing a line from its "bottom-left" corner. Here's the sequence of instructions:

Draw me a rectangle
[now imagine where is the bottom-left corner of that rectangle and keep it in mind]
Rotate the rectangle counter-clockwise by 90 degrees.
[in your opinion, where is the bottom-left now??]
Draw a 2cm vertical line down from the bottom left hand corner of that rectangle.

The unexpected outcome was that the AI drew the line from what humans would perceive as the bottom-right corner of the rotated rectangle. For a human, after rotation, the original bottom-left corner has moved and is now visually the top-left. We would naturally identify the new bottom-left based on its current spatial position. The AI, however, seemed to retain its understanding of the "bottom-left" based on the rectangle's initial creation, before any transformation.

Understanding the Frame-of-Reference Ambiguity

User beenish-1 provided a clear explanation for this behavior, confirming it's a common "frame-of-reference ambiguity" rather than a lack of geometric understanding. When a rectangle is created, its corners are defined as fixed vertices (e.g., bottomLeft, bottomRight). While rotating the rectangle transforms its coordinates visually, the internal labels for these vertices in the AI's memory often don't automatically update to reflect their new spatial orientation.

This leads to two distinct interpretations:

  • Object-relative: The AI defaults to this, where "bottom-left" refers to the original, fixed vertex label, regardless of its current visual position after rotation.
  • World-relative: Humans naturally adopt this, reinterpreting "bottom-left" as the vertex with the lowest X and Y coordinates in the current screen or world space after all transformations.

Most AI tools, by default, stick to the object-relative interpretation, causing a disconnect when human instructions assume a world-relative understanding.

A developer providing explicit instructions to an AI assistant to recalculate geometric positions after transformation.
A developer providing explicit instructions to an AI assistant to recalculate geometric positions after transformation.

Aligning AI and Human Perspectives for Better Software Engineering Goals

This issue isn't confined to simple rectangles; it frequently arises in UI development, CAD, and various rendering scenarios where transformations alter orientation without explicitly relabeling vertices. Recognizing this difference is crucial for developers aiming to achieve precise software engineering goals with AI assistance.

The key to overcoming this ambiguity, as suggested by beenish-1, is to be explicit in your instructions. Instead of assuming the AI will re-evaluate spatial positions, guide it to do so:

“Rotate the rectangle 90° counter-clockwise, then determine which vertex is now the bottom-left in world coordinates, and draw the line from that point.”

By explicitly instructing the AI to recalculate the "bottom-left" based on its current world coordinates, developers can bridge the gap between AI's internal object-relative understanding and human world-relative intuition. This insight underscores the importance of understanding the underlying logic of our AI tools, enabling us to phrase prompts more effectively and ultimately enhance developer productivity and the quality of our code.