From 978ae2e725cc2437d85ea1f8d35d23a224a866d9 Mon Sep 17 00:00:00 2001 From: mtgmonkey Date: Thu, 27 Nov 2025 22:27:31 +0100 Subject: [PATCH] add basic geometric data types --- src/Model.hs | 94 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/src/Model.hs b/src/Model.hs index 05946a1..3e846e4 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -13,7 +13,93 @@ data Model = Model { counter :: Integer } --- DEFAULTS -- -model = Model - { counter = 0 - } +-- absolute objects + +data AbsoluteObject + = AbsoluteObject [AbsoluteObject] + | AbsolutePoint Point + | PinnedRelativeObject Point RelativeObject + +data Point + = Point + { x :: Float + , y :: Float + , z :: Float + , k :: Float + } + +data Line + = Line Point Point + +data Triangle + = Triangle Point Point Point + +-- relative objects + +data RelativeObject + = RelativeObject [RelativeObject] + | RelativeHVolume HVolume + | RelativeVolume Volume + | RelativeSurface Surface + +data HVolume + = HSphere Float + | HPrism Float Volume + +data Volume + = Sphere Float + | Prism Float Surface + +data Surface + = Circle Float + | Square Float + +-- CONSTRUCTORS -- + +model :: Model +model = + Model + { counter = 0 + } + +-- absolutes + +point :: Point +point = + Point + { x = 0 + , y = 0 + , z = 0 + , k = 0 + } + +origin :: Point +origin = point + +line :: Line +line = Line point point + +triangle :: Triangle +triangle = Triangle point point point + +-- relatives + +hSphere :: HVolume +hSphere = HSphere 1 + +hPrism :: HVolume +hPrism = HPrism 1 prism + +-- Volumes + +sphere :: Volume +sphere = Sphere 1 + +prism :: Volume +prism = Prism 1 square + +circle :: Surface +circle = Circle 1 + +square :: Surface +square = Square 1