Search code examples
c#wpfisometric

Formula for trying to get the length of an isometric shadow?


I'm creating a canvas with isometric blocks on it. What I want to do is cast a shadow from the blocks. I currently have a version of it working, but the shadow appears a lot longer than it should. I was wondering if there was any formula to work out how to cast a shadow properly.

What I would like is the shadow to be slightly shorter than the height.

So far
(source: net84.net)

Regards Peter


Solution

  • Formula?

    Its trigonometry:

    The light source vector is side c of a triangle, your block the a side.

    a^2 + b^2 = c^2
    

    Or the length of the shadow being b

    b^2 = c^2 - a^2
    

    or

    b = square root of (c^2 - a^2)
    

    PS this is predicated on the angle of a & b being 90 degrees, aka your block stands straight up. Otherwise you'll need to use the angle between a & c and then use cos, sin and or tangent to figure the length of side b. I forget exactly, but you can ask here: https://math.stackexchange.com/

    See this calculator: http://www.carbidedepot.com/formulas-trigright.asp