2026年1月14日星期三

Tech Art - Spring - HW1 - Vector Calculator

 

Result:



Assignment contents: 


Analysis:

This assignment does not require a large amount of analysis. From the provided example file, it is already very clear what we are expected to build. In essence, it is just implementing a set of math operations and visualizing the results, so the overall complexity is not high.

The only detail that needs special attention is that the vectors use homogeneous coordinates: w = 0 represents a direction vector, and w = 1 represents a point. As long as you handle the arithmetic rules between points and direction vectors correctly, everything will be fine. That mainly means you should separate cases and apply the correct semantics for each operation.

For example:

  • Addition

    • Point + Direction = Point
      (translate a point by a direction)

    • Direction + Direction = Direction
      (vector addition)

    • Point + Point = Undefined / Not Allowed
      (adding two positions usually has no geometric meaning)

  • Subtraction

    • Point − Point = Direction
      (direction from the second point to the first point)

    • Point − Direction = Point
      (move the point backward along the direction)

    • Direction − Direction = Direction
      (vector difference)

    • Direction − Point = Undefined / Not Allowed
      (subtracting a position from a direction is not meaningful)

  • Scalar multiplication

    • Direction × Scalar = Direction
      (scale direction magnitude)

    • Point × Scalar = Typically Not Allowed
      (scaling a point is not a standard affine operation unless you explicitly define an origin-based scaling rule; most pipelines treat this as undefined)

  • Dot product

    • Only defined for Direction · Direction → float

    • If a point is involved, you should either reject it or explicitly interpret it as a direction from the origin (but that changes meaning, so rejecting is usually cleaner for assignments).

  • Cross product

    • Only defined for Direction × Direction → Direction

    • Point involvement should be rejected.

  • Unitize (~)

    • Only defined for Direction → Direction

    • Unitizing a point should be rejected.

  • Angle between

    • Only defined for Direction vs Direction → float (degrees)

    • If either is zero-length, no valid solution.


P4V:





没有评论:

发表评论