' Geometry shapes: point, line, circle, rectangle with area/perimeter calculations
#COMPILE EXE
#DIM ALL

TYPE Point2D
    x AS DOUBLE
    y AS DOUBLE
END TYPE

TYPE Line2D
    x1 AS DOUBLE
    y1 AS DOUBLE
    x2 AS DOUBLE
    y2 AS DOUBLE
END TYPE

TYPE Circle2D
    cx AS DOUBLE
    cy AS DOUBLE
    radius AS DOUBLE
END TYPE

TYPE Rectangle2D
    x AS DOUBLE
    y AS DOUBLE
    w AS DOUBLE
    h AS DOUBLE
END TYPE

FUNCTION PBMAIN() AS LONG
    LOCAL p1 AS Point2D
    LOCAL p2 AS Point2D
    LOCAL line1 AS Line2D
    LOCAL c1 AS Circle2D
    LOCAL c2 AS Circle2D
    LOCAL r1 AS Rectangle2D
    LOCAL dx AS DOUBLE
    LOCAL dy AS DOUBLE
    LOCAL dist AS DOUBLE
    LOCAL lineLen AS DOUBLE
    LOCAL slope AS DOUBLE
    LOCAL circleCirc AS DOUBLE
    LOCAL circleArea AS DOUBLE
    LOCAL rectPerim AS DOUBLE
    LOCAL rectArea AS DOUBLE

    PRINT "Geometry Calculator"
    PRINT ""

    p1.x = 0.0
    p1.y = 0.0
    p2.x = 3.0
    p2.y = 4.0
    PRINT "Point 1: (" + STR$(p1.x) + "," + STR$(p1.y) + ")"
    PRINT "Point 2: (" + STR$(p2.x) + "," + STR$(p2.y) + ")"
    dx = p2.x - p1.x
    dy = p2.y - p1.y
    dist = SQR(dx * dx + dy * dy)
    PRINT "Distance: " + STR$(dist)

    PRINT ""
    line1.x1 = 1.0
    line1.y1 = 1.0
    line1.x2 = 5.0
    line1.y2 = 5.0
    PRINT "Line from (" + STR$(line1.x1) + "," + STR$(line1.y1) + ") to (" + STR$(line1.x2) + "," + STR$(line1.y2) + ")"
    dx = line1.x2 - line1.x1
    dy = line1.y2 - line1.y1
    lineLen = SQR(dx * dx + dy * dy)
    PRINT "Length: " + STR$(lineLen)

    PRINT ""
    c1.cx = 0.0
    c1.cy = 0.0
    c1.radius = 5.0
    PRINT "Circle 1: center(" + STR$(c1.cx) + "," + STR$(c1.cy) + ") radius=" + STR$(c1.radius)
    circleCirc = 2.0 * 3.14159265 * c1.radius
    circleArea = 3.14159265 * c1.radius * c1.radius
    PRINT "Circumference: " + STR$(circleCirc)
    PRINT "Area: " + STR$(circleArea)

    PRINT ""
    c2.cx = 3.0
    c2.cy = 4.0
    c2.radius = 3.0
    PRINT "Circle 2: center(" + STR$(c2.cx) + "," + STR$(c2.cy) + ") radius=" + STR$(c2.radius)

    PRINT ""
    r1.x = 0.0
    r1.y = 0.0
    r1.w = 4.0
    r1.h = 3.0
    PRINT "Rectangle: (" + STR$(r1.x) + "," + STR$(r1.y) + ") w=" + STR$(r1.w) + " h=" + STR$(r1.h)
    rectPerim = 2.0 * (r1.w + r1.h)
    rectArea = r1.w * r1.h
    PRINT "Perimeter: " + STR$(rectPerim)
    PRINT "Area: " + STR$(rectArea)

    PRINT ""
    PRINT "Geometry operations complete."
    FUNCTION = 0
END FUNCTION
