i've got a formula for calculating the area of a triangle:
vb Code:
x1 = points(1).X y1 = points(1).Y x2 = points(2).X y2 = points(2).Y x3 = points(0).X y3 = points(0).Y Dim area As Decimal = (0.5 * ((x1 * (y2 - y3)) + (x2 * (y3 - y1)) + (x3 * (y1 - y2)))) Debug.Print(unitConverter.pixelsSquaredToCMSquared(gr, area))
it works well but it calculates the output in pixels² + i need it to be cm²
heres my converter function that works well converting a pixel length to a cm length, but doesn't work with pixels²:
vb Code:
Public Shared Function pixelsSquaredToCMSquared(ByVal gr As Graphics, ByVal pixels As Decimal) As Decimal Return (pixels / gr.DpiX) * 2.54 End Function
what am i doing wrong?




Reply With Quote