Safe HaskellNone

AronGraphic

Synopsis
  • lightDiffuse :: Color4 GLfloat
  • lightAmbient :: Color4 GLfloat
  • lightPosition :: Vertex4 GLfloat
  • lightSpecular :: Color4 GLfloat
  • scaleFont :: GLdouble
  • red :: Color3 GLdouble
  • green :: Color3 GLdouble
  • blue :: Color3 GLdouble
  • white :: Color3 GLdouble
  • black :: Color3 GLdouble
  • gray :: Color3 GLdouble
  • gray1 :: Color3 GLdouble
  • cyan :: Color3 GLdouble
  • magenta :: Color3 GLdouble
  • yellow :: Color3 GLdouble
  • color1 :: Color3 GLdouble
  • color2 :: Color3 GLdouble
  • color3 :: Color3 GLdouble
  • color4 :: Color3 GLdouble
  • color5 :: Color3 GLdouble
  • data SegEndPt
  • data NormalDir
  • dist :: Floating a => Vertex3 a -> Vertex3 a -> a
  • distX :: Floating a => Vertex3 a -> Vertex3 a -> a
  • sqdist :: Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat
  • dot3ve :: Num a => Vector3 a -> Vector3 a -> a
  • dot3vx :: Num a => Vertex3 a -> Vertex3 a -> a
  • (+:) :: Num a => Vertex3 a -> Vector3 a -> Vertex3 a
  • (-:) :: Num a => Vertex3 a -> Vertex3 a -> Vector3 a
  • (⊥) :: Vector3 GLfloat -> Vector3 GLfloat
  • perpcw :: Num a => Vector3 a -> Vector3 a
  • perpccw :: Num a => Vector3 a -> Vector3 a
  • (*:) :: Num a => a -> Vector3 a -> Vector3 a
  • (/:) :: (Num a, Fractional a) => Vector3 a -> Integer -> Vector3 a
  • (**:) :: Num a => a -> Vertex3 a -> Vertex3 a
  • (×) :: Num a => a -> [a] -> [a]
  • (××) :: Num a => a -> [[a]] -> [[a]]
  • (*>:) :: Num a => a -> Vertex3 a -> Vertex3 a
  • (>>:) :: Num a => a -> Vector3 a -> Vector3 a
  • (∈) :: (Num a, Ord a) => a -> [a] -> Bool
  • (∎) :: GLfloat -> Vector3 GLfloat -> Vector3 GLfloat
  • v2x :: Num a => Vector3 a -> Vertex3 a
  • x2v :: Num a => Vertex3 a -> Vector3 a
  • skew :: Num a => Vertex3 a -> [[a]]
  • skew' :: Num a => Vector3 a -> [[a]]
  • skewVec :: Num a => Vector3 a -> [[a]]
  • (⊗) :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a)
  • cross :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a)
  • crossX :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a)
  • crossF :: Vector3 GLdouble -> Vector3 GLdouble -> Maybe (Vector3 GLdouble)
  • isCoplanar :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Bool
  • normal3 :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Maybe (Vector3 a)
  • vec :: Num a => Vertex3 a -> Vertex3 a -> Vector3 a
  • ray :: Vertex3 GLfloat -> GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat
  • ray2 :: GLfloat -> Vertex3 GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat
  • perpenLine :: GLfloat -> GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> [Vertex3 GLfloat]
  • curvePt :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> [Vertex3 GLfloat]
  • curvePtD :: (GLdouble -> GLdouble) -> (GLdouble, GLdouble) -> [Vertex3 GLdouble]
  • curvePtV :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Vector (Vertex3 GLfloat)
  • drawCurve :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Color3 GLdouble -> IO ()
  • drawCurveList :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO ()
  • drawCurveListWithEndPt :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO ()
  • drawCurveD :: (GLdouble -> GLdouble) -> (GLdouble, GLdouble) -> Color3 GLdouble -> IO ()
  • drawCurveV :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Color3 GLdouble -> IO ()
  • drawSurface :: (GLfloat -> GLfloat -> GLfloat) -> IO ()
  • drawSurfaceR :: (GLfloat -> GLfloat -> GLfloat) -> GLfloat -> IO ()
  • plotPts :: Color3 GLdouble -> [GLfloat] -> IO ()
  • tangentLine :: Fractional a => (a -> a) -> (a, a) -> a -> [Vertex3 a]
  • interpolate' :: Fractional a => Integer -> Vertex3 a -> Vertex3 a -> [Vertex3 a]
  • drawTangentLine :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> Color3 GLdouble -> IO ()
  • normalLine :: NormalDir -> (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> [Vertex3 GLfloat]
  • normalLineNew :: NormalDir -> (GLfloat -> GLfloat) -> GLfloat -> GLfloat -> [Vertex3 GLfloat]
  • drawNormalLine :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> Color3 GLdouble -> IO ()
  • drawNormalLineNew :: (GLfloat -> GLfloat) -> GLfloat -> GLfloat -> Color3 GLdouble -> IO ()
  • cen :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat
  • middle :: Floating a => Vertex3 a -> Vertex3 a -> Vertex3 a
  • isPerpen :: Vector3 GLfloat -> Vector3 GLfloat -> Bool
  • isColinear :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • isColinear2d :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • isColinear3d :: Vertex3 GLdouble -> Vertex3 GLdouble -> Vertex3 GLdouble -> Bool
  • isInSegment :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe Bool
  • data PtSeg
  • ptOnSegment :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> PtSeg
  • drawPrimitive :: PrimitiveMode -> Color3 GLdouble -> [(GLfloat, GLfloat, GLfloat)] -> IO ()
  • drawPrimitiveVex :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawTriangleList :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawTriangleStrip :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawTriangleVex :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • triangle :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • drawPrimitive' :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawPrimitive2 :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLdouble] -> IO ()
  • drawPrimitiveX :: PrimitiveMode -> [Vertex3 GLdouble] -> [Color3 GLdouble] -> IO ()
  • drawLines :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentWithEndPt :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentNoEndPt :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentNoEndPt2 :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO ()
  • drawFatSegmentEndPt :: GLfloat -> [Vertex3 GLfloat] -> IO ()
  • drawSegments :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentls :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentList :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegment :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • drawSegmentD :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO ()
  • drawSeg :: Color3 GLdouble -> (GLdouble, GLdouble, GLdouble) -> (GLdouble, GLdouble, GLdouble) -> IO ()
  • drawSegNoEnd :: Color3 GLdouble -> (GLdouble, GLdouble, GLdouble) -> (GLdouble, GLdouble, GLdouble) -> IO ()
  • drawSegmentNoEnd :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • drawSegmentNoEnd2 :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO ()
  • drawSegment' :: SegEndPt -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentArg :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> IO ()
  • drawSpherePt :: Vertex3 GLfloat -> GLfloat -> [Vertex3 GLfloat]
  • spherePts :: [[Vertex3 GLfloat]]
  • drawSphere :: IO ()
  • drawSphereN :: Int -> GLfloat -> [Color3 GLdouble] -> IO ()
  • drawParaboloid :: IO ()
  • drawConic :: IO ()
  • drawGrid :: IO ()
  • drawPlane :: Color3 GLdouble -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> IO ()
  • circlePt :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat]
  • circlePtD :: Vertex3 GLdouble -> Double -> Int -> [Vertex3 GLdouble]
  • circle' :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat]
  • circle'X :: Vertex3 GLfloat -> GLfloat -> [Vertex3 GLfloat]
  • circle2 :: Vertex3 GLdouble -> Double -> [Vertex3 GLdouble]
  • circleN :: Vertex3 GLfloat -> Double -> Integer -> [Vertex3 GLfloat]
  • circleNX :: Vertex3 GLfloat -> GLfloat -> Int -> [Vertex3 GLfloat]
  • vec_ :: (Fractional a, Eq a) => Vertex3 a -> Vector3 a
  • ver_ :: (Fractional a, Eq a) => Vector3 a -> Vertex3 a
  • drawCircleFilled :: Color3 GLdouble -> Vertex3 GLfloat -> GLfloat -> IO ()
  • circleNArc :: Vertex3 GLdouble -> Double -> Integer -> (GLdouble, GLdouble) -> [Vertex3 GLdouble]
  • circleXY :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat]
  • circleXZ :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat]
  • circleYZ :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat]
  • drawDot :: Vertex3 GLfloat -> IO ()
  • drawDotX :: Color3 GLdouble -> Vertex3 GLfloat -> IO ()
  • drawDotXX :: Color3 GLdouble -> Vertex3 GLfloat -> GLfloat -> IO ()
  • drawDotR :: Vertex3 GLfloat -> Double -> IO ()
  • drawDotColor :: Vertex3 GLfloat -> Color3 GLdouble -> IO ()
  • drawDotRColor :: Vertex3 GLfloat -> GLdouble -> Color3 GLdouble -> IO ()
  • cartToPolar :: Vector3 GLfloat -> (GLfloat, GLfloat)
  • vecToM3x :: Vector3 GLdouble -> [[GLdouble]]
  • vecToM3y :: Vector3 GLdouble -> [[GLdouble]]
  • vecToM3z :: Vector3 GLdouble -> [[GLdouble]]
  • rotx :: Floating a => a -> [[a]]
  • roty :: Floating a => a -> [[a]]
  • rotz :: Floating a => a -> [[a]]
  • coordTip :: Color3 GLdouble -> IO ()
  • coordTipX :: Color3 GLdouble -> GLdouble -> IO ()
  • coordTipY :: Color3 GLdouble -> GLdouble -> IO ()
  • coordTipZ :: Color3 GLdouble -> GLdouble -> IO ()
  • show3dStr :: String -> Color3 GLdouble -> GLdouble -> IO ()
  • renderCoordinates :: IO ()
  • drawCircleVec :: GLfloat -> Vertex3 GLfloat -> Vector3 GLfloat -> IO ()
  • matVx :: [[a]] -> Vertex3 a
  • matVe :: [[a]] -> Vector3 a
  • veMat :: Vector3 a -> [[a]]
  • drawRect :: (Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • drawRectColor :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO ()
  • drawRectColor2 :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO ()
  • drawRect2d :: (GLfloat, GLfloat) -> IO ()
  • drawQuads :: [Vertex3 GLfloat] -> IO ()
  • drawQuadsColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawQuadsXZColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawQuadsYZColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawRectFill2d :: Color3 GLdouble -> (GLfloat, GLfloat) -> IO ()
  • drawRectFill2dX :: Color3 GLdouble -> (GLfloat, GLfloat) -> IO ()
  • drawHis :: [GLfloat] -> IO ()
  • drawHisgram :: [GLfloat] -> IO ()
  • renderText :: String -> IO ()
  • drawCircle' :: Vertex3 GLfloat -> Double -> IO ()
  • drawCircle2 :: Vertex3 GLfloat -> Double -> IO ()
  • drawCircleThreePt :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Color3 GLdouble -> IO ()
  • drawCircleThreePtList :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO ()
  • drawCircleThreePtListX :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • threePtCircle :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat)
  • threePtCircleList :: [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat)
  • center :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat
  • drawCircleColorN :: Vertex3 GLfloat -> Double -> Color3 GLdouble -> Integer -> IO ()
  • drawCircleXYZ :: Vertex3 GLfloat -> Double -> IO ()
  • drawCircleXYZColor :: Vertex3 GLfloat -> Double -> Color3 GLdouble -> IO ()
  • drawCircleColor :: Vertex3 GLfloat -> Color3 GLdouble -> Double -> IO ()
  • drawCircleColor2 :: Vertex3 GLdouble -> Color3 GLdouble -> Double -> IO ()
  • drawCircleColor' :: Color3 GLdouble -> Double -> Vertex3 GLfloat -> IO ()
  • conic :: [(GLfloat, GLfloat, GLfloat)]
  • det2 :: Num a => [[a]] -> a
  • inverseR :: [[Rational]] -> [[Rational]]
  • inv2 :: Fractional a => [[a]] -> [[a]]
  • data SegColinear
  • fourPtColinear :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> SegColinear
  • intersectLineTri :: (Vertex3 GLdouble, Vertex3 GLdouble) -> (Vertex3 GLdouble, Vertex3 GLdouble, Vertex3 GLdouble) -> Maybe (Vertex3 GLdouble)
  • intersectLine :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat, [[GLfloat]])
  • intersectLine2 :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat, (GLfloat, GLfloat))
  • onePtOverlappedSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat, (GLfloat, GLfloat))
  • intersectLine' :: [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat, [[GLfloat]])
  • pointToLine :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat
  • vecToVex :: Vector3 a -> Vertex3 a
  • vexToVec :: Vertex3 a -> Vector3 a
  • vecToList :: Vector3 a -> [a]
  • vexToList :: Vertex3 a -> [a]
  • listToVec :: [a] -> Vector3 a
  • listToVex :: [a] -> Vertex3 a
  • listToVer :: [a] -> Vertex3 a
  • projOnPlane :: (Num a, Eq a) => Vector3 a -> (Vector3 a, Vector3 a) -> Vector3 a
  • ptToLine3d :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat
  • angle2Vector :: Floating a => Vector3 a -> Vector3 a -> a
  • ptToLine :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat
  • intersectSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat)
  • intersectSegNoEndPt :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat)
  • intersectSegNoEndPt2 :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat)
  • isIntersectedSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Bool
  • intersectLineR :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational, [[Rational]])
  • threePtDeterminant :: Fractional a => Vertex3 a -> Vertex3 a -> Vertex3 a -> a
  • threePtCCW :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • threePtCW :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • threePtCollinear :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • ptOnLeftLine :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool
  • ptInsideTri :: (Floating a, Ord a) => Vertex3 a -> (Vertex3 a, Vertex3 a, Vertex3 a) -> (Bool, a)
  • isPtInsideTri :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat)
  • isPtInsideTriList :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> (Bool, GLfloat)
  • perpPlane :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational)
  • lineIntersectPlane :: Vertex3 GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational)
  • convexHull :: Int -> [Vertex3 GLfloat] -> [[Vertex3 GLfloat]]
  • convexHull2 :: Int -> [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • convexHullAllSeg :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • vertexWithAllTri :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Vertex3 GLfloat -> [[Vertex3 GLfloat]]
  • meshAllTriangle :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [Vertex3 GLfloat] -> [[Vertex3 GLfloat]]
  • drawTriangulation :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> (GLfloat, GLfloat) -> IO ()
  • drawTriangulationWithCircle :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> (GLfloat, GLfloat) -> IO ()
  • collectSegment :: [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • triangulateSimple :: [Vertex3 GLfloat] -> [Vertex3 GLfloat] -> [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))] -> [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))]
  • lsToTup2 :: [Vertex3 GLfloat] -> (Vertex3 GLfloat, Vertex3 GLfloat)
  • lsToTup3 :: [Vertex3 GLfloat] -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)
  • tupTols3 :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> [Vertex3 GLfloat]
  • tupTols2 :: (Vertex3 GLfloat, Vertex3 GLfloat) -> [Vertex3 GLfloat]
  • flipEdge :: Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Maybe ((Vertex3 GLfloat, Vertex3 GLfloat), (Vertex3 GLfloat, Vertex3 GLfloat), [(Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)])
  • isPtOnInscribeCircle :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat)
  • isPtInsideInscribeCircle :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat)
  • intersectSegNoEndPt3 :: [Vertex3 GLfloat] -> [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat)
  • cmpVex :: Vertex3 GLfloat -> Vertex3 GLfloat -> Bool
  • sortVex :: [[Vertex3 GLfloat]] -> [[Vertex3 GLfloat]]
  • sortVexL :: [Vertex3 GLfloat] -> [Vertex3 GLfloat]
  • intersectSegNoEndPtList :: (Vertex3 GLfloat, Vertex3 GLfloat) -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [Maybe (Vertex3 GLfloat, (Vertex3 GLfloat, Vertex3 GLfloat))]
  • convexHull3 :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • convexHull4X :: [Vertex3 GLfloat] -> Bool -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • convexHullLoop :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • shiftX :: Floating a => Vertex3 a -> a -> Vertex3 a
  • shiftXList :: Floating a => [Vertex3 a] -> a -> [Vertex3 a]
  • shiftY :: Num a => Vertex3 a -> a -> Vertex3 a
  • shiftYList :: Num a => [Vertex3 a] -> a -> [Vertex3 a]
  • shiftXY :: Num a => (a, a) -> Vertex3 a -> Vertex3 a
  • shiftXYList :: Num a => (a, a) -> [Vertex3 a] -> [Vertex3 a]
  • shiftTriX :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)
  • shiftTriY :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)
  • ptInsidePolygon :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> Bool
  • containPt :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> Bool
  • projv :: Fractional a => Vector3 a -> Vector3 a -> Vector3 a
  • perpPlaneX :: (Fractional a, Eq a) => Vertex3 a -> (Vertex3 a, Vertex3 a, Vertex3 a) -> Vertex3 a
  • nr :: Floating a => Vector3 a -> a
  • uv :: Floating a => Vector3 a -> Vector3 a
  • normalizeV3 :: Floating a => Vector3 a -> Vector3 a
  • rod :: (Eq a, Floating a) => Vector3 a -> Vector3 a -> a -> Vector3 a
  • cosVex3 :: Floating a => Vertex3 a -> Vertex3 a -> Vertex3 a -> a
  • angleThreePts :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat
  • angle3Pts :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat
  • nonCrossSegmentNoEndPt :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • rmAdjacentSeg :: Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [(Vertex3 GLfloat, Vertex3 GLfloat)]
  • affineTri :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> [Vertex3 GLfloat]
  • drawSegmentFromTo :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO ()
  • drawSegmentFromTo2 :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO ()
  • drawSegmentFromToD :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO ()
  • grid :: [[Vertex3 GLfloat]]
  • grid2 :: (GLfloat -> GLfloat -> GLfloat) -> [[Vertex3 GLfloat]]
  • grid3 :: (GLfloat -> GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> [[Vertex3 GLfloat]]
  • drawParamSurf :: (GLfloat -> GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> IO ()
  • torus2 :: [[Vertex3 GLfloat]]
  • drawTorus2 :: IO ()
  • drawTorus :: GLfloat -> GLfloat -> Int -> [Color3 GLdouble] -> IO ()
  • type Fx = Int -> Int -> GLfloat
  • type Fy = Int -> Int -> GLfloat
  • type Fz = Int -> Int -> GLfloat
  • type Fx' = Int -> Int -> GLdouble
  • type Fy' = Int -> Int -> GLdouble
  • type Fz' = Int -> Int -> GLdouble
  • drawParamSurface :: Fx -> Fy -> Fz -> IO ()
  • drawParamSurfaceN :: Fx -> Fy -> Fz -> Int -> IO ()
  • combinePt :: Num a => [[Vertex3 a]] -> [Color3 GLdouble] -> [[(Color3 GLdouble, Vertex3 a)]]
  • drawParamSphere :: Fx -> Fy -> Fz -> Int -> [Color3 GLdouble] -> IO ()
  • drawCubeQuadX :: Vertex3 GLdouble -> GLdouble -> IO ()
  • drawCubeQuadT :: (GLdouble, Vertex3 GLdouble) -> IO ()
  • drawCubeQuad :: GLfloat -> IO ()
  • drawCubeQuadD :: GLdouble -> IO ()
  • drawParamSurfaceN_new :: Fx -> Fy -> Fz -> Int -> IO ()
  • geneParamSurface :: Fx -> Fy -> Fz -> Int -> [[Vertex3 GLfloat]]
  • drawSurfaceFromList :: [[Vertex3 GLfloat]] -> IO ()
  • grid2Ratio :: (GLfloat -> GLfloat -> GLfloat) -> GLfloat -> [[Vertex3 GLfloat]]
  • list3ToVertex3 :: Show a => [a] -> Vertex3 a
  • vertex3ToList :: Vertex3 a -> [a]
  • readGLScript :: FilePath -> IO [String]
  • strToVector3 :: String -> Vector3 GLdouble
  • strToTriple :: String -> (GLfloat, GLfloat, GLfloat)
  • vertex3ToTriple :: Vertex3 GLfloat -> (GLfloat, GLfloat, GLfloat)
  • tripleToVertex3 :: (GLfloat, GLfloat, GLfloat) -> Vertex3 GLfloat
  • strToVertex3 :: String -> Vertex3 GLfloat
  • strToVertex3' :: String -> Vertex3 GLdouble
  • takeVertex3 :: [String] -> [Vertex3 GLdouble]
  • drawComplex :: (Complex GLfloat -> Complex GLfloat) -> GLfloat -> IO ()

Documentation

lightDiffuse :: Color4 GLfloat Source #

Unboxed Arrays: Data.Vector.Unboxed

Bool () Char Double Float Int Int8, 16, 32, 64 Word Word8, 16, 32, 64 Complex a's, where a is in Unbox Tuple types, where the elements are unboxable

lightAmbient :: Color4 GLfloat Source #

lightPosition :: Vertex4 GLfloat Source #

lightSpecular :: Color4 GLfloat Source #

scaleFont :: GLdouble Source #

KEY: draw string, render string

   GL.scale (1scaleFont :: GL.GLdouble) (1scaleFont) 1
   GLUT.renderString GLUT.Roman str

   strWidth <- GLUT.stringWidth GLUT.Roman str
   strHeight <- GLUT.stringHeight GLUT.Roman str
   

red :: Color3 GLdouble Source #

  • ------------------------------------------------------------------------------- | Fri Dec 7 14:35:38 2018 | three colors: data Color3 a = Color3 !a !a !a | Add more colors: Sun 27 Jun 23:56:15 2021

green :: Color3 GLdouble Source #

blue :: Color3 GLdouble Source #

white :: Color3 GLdouble Source #

black :: Color3 GLdouble Source #

gray :: Color3 GLdouble Source #

gray1 :: Color3 GLdouble Source #

cyan :: Color3 GLdouble Source #

magenta :: Color3 GLdouble Source #

yellow :: Color3 GLdouble Source #

color1 :: Color3 GLdouble Source #

color2 :: Color3 GLdouble Source #

color3 :: Color3 GLdouble Source #

color4 :: Color3 GLdouble Source #

color5 :: Color3 GLdouble Source #

data SegEndPt Source #

Constructors

No 
End 
Beg 
Both 
Cen 
All 

data NormalDir Source #

counter clockwise | clock wise

Constructors

NCCW 
NCW 

Instances

Instances details
Eq NormalDir Source # 
Instance details

Defined in AronGraphic

Methods

(==) :: NormalDir -> NormalDir -> Bool

(/=) :: NormalDir -> NormalDir -> Bool

dist :: Floating a => Vertex3 a -> Vertex3 a -> a Source #

Compute the distance between two points

\( v = (x, y, z) \)

\( \| v \| = \sqrt{ x^2 + y^2 + z^2} = \sqrt{ v \cdot v} \)

let v1 = Vertex3 1 2 3
let v2 = Vertex3 2 3 4
dist v1 v2

distX :: Floating a => Vertex3 a -> Vertex3 a -> a Source #

Compute the distance between two points

\( v = (x, y, z) \)

\( \| v \| = \sqrt{ x^2 + y^2 + z^2} = \sqrt{ v \cdot v} \)

let v1 = Vertex3 1 2 3
let v2 = Vertex3 2 3 4
distX v1 v2

sqdist :: Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat Source #

Compute the norm-squared

\( v = (x, y, z)\)

\( |v|^2 = x^2 + y^2 + z^2 \)

let v1 = Vertex3 1 2 3
let v2 = Vertex3 2 3 4
sqdist v1 v2

dot3ve :: Num a => Vector3 a -> Vector3 a -> a Source #

KEY: dot product of two Vector3

dot3vx :: Num a => Vertex3 a -> Vertex3 a -> a Source #

dot product for Vertex3

(+:) :: Num a => Vertex3 a -> Vector3 a -> Vertex3 a Source #

KEY: add vertex to vector, vector to vertex, translate vectex to other vectex, affine transform

NOTE: Points and Vectors in afine space

0 + vector => vector vextex + vector => vextex vextex - vectex => vector 0 - 0 => 0 vector

(-:) :: Num a => Vertex3 a -> Vertex3 a -> Vector3 a Source #

KEY: vertex to vector, vector from two Vertex3, vector = Vertex3 - Vertex3

(⊥) :: Vector3 GLfloat -> Vector3 GLfloat Source #

perpcw :: Num a => Vector3 a -> Vector3 a Source #

KEY: perpendicular vector

URL: perpendicular_vector

perpccw :: Num a => Vector3 a -> Vector3 a Source #

KEY: perpendicular vector

URL: perpendicular_vector

(*:) :: Num a => a -> Vector3 a -> Vector3 a Source #

KEY: Scalar multiplies a vector

(/:) :: (Num a, Fractional a) => Vector3 a -> Integer -> Vector3 a Source #

(**:) :: Num a => a -> Vertex3 a -> Vertex3 a Source #

KEY: scalar multiplies vertex, vertex multiplies scalar

(×) :: Num a => a -> [a] -> [a] Source #

(××) :: Num a => a -> [[a]] -> [[a]] Source #

(*>:) :: Num a => a -> Vertex3 a -> Vertex3 a Source #

(>>:) :: Num a => a -> Vector3 a -> Vector3 a Source #

(∈) :: (Num a, Ord a) => a -> [a] -> Bool Source #

dot product odot (⊙)::Vector3 GLfloat -> Vector3 GLfloat -> GLfloat (⊙) (Vector3 x0 y0 z0) (Vector3 x1 y1 z1) = (x0*x1) + (y0*y1) + (z0*z1)

(∎) :: GLfloat -> Vector3 GLfloat -> Vector3 GLfloat Source #

v2x :: Num a => Vector3 a -> Vertex3 a Source #

x2v :: Num a => Vertex3 a -> Vector3 a Source #

skew :: Num a => Vertex3 a -> [[a]] Source #

Shorten realToFrac rf::(Real a, Fractional b) => a -> b rf = realToFrac

Form a skew symmetric matrix from \( \color{red}{Vertex3} \)

cross product of a x b = [a] b where [a] is skew symmetric matrix from vector a colIndex x rowIndex = [c][r]

Vertex3 a1 a2 a3

\[ \begin{bmatrix} 0 & -a_3 & a_2 \\ a_3 & 0 & -a_1 \\ -a_2 & a_1 & 0 \\ \end{bmatrix} \]

skew' :: Num a => Vector3 a -> [[a]] Source #

  • deprecated,

Use skewVec, better name

Form a skew symmetric matrix from \( \color{red}{Vector3} \)

cross product of a x b = [a] b where [a] is skew symmetric matrix from vector a colIndex x rowIndex = [c][r]

Vertex3 a1 a2 a3

\[ \begin{bmatrix} 0 & -a_3 & a_2 \\ a_3 & 0 & -a_1 \\ -a_2 & a_1 & 0 \\ \end{bmatrix} \]

skewVec :: Num a => Vector3 a -> [[a]] Source #

Form a skew symmetric matrix from \( \color{red}{Vector3} \)

cross product of a x b = [a] b where [a] is skew symmetric matrix from vector a colIndex x rowIndex = [c][r]

Vertex3 a1 a2 a3

\[ \begin{bmatrix} 0 & -a_3 & a_2 \\ a_3 & 0 & -a_1 \\ -a_2 & a_1 & 0 \\ \end{bmatrix} \]

(⊗) :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a) Source #

KEY: Cross product of two vectors. unicode code

  • The direction is determinated by the the Right Hand Rule

NOTE: deprecated, use crossF

cross :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a) Source #

KEY: Cross product of two vectors. unicode code

  • The directin is determinated by the the Right Hand Rule

NOTE: deprecated, use crossF

crossX :: (Num a, Eq a) => Vector3 a -> Vector3 a -> Maybe (Vector3 a) Source #

KEY: Cross product of two vectors. unicode code

NOTE: deprecated, use crossF

crossF :: Vector3 GLdouble -> Vector3 GLdouble -> Maybe (Vector3 GLdouble) Source #

KEY: Cross product using Fractional

DATE: Thu 14 Mar 20:14:11 2024

NOTE: epsilon = 1e-12

  • The direction is determinated by the the Right Hand Rule

NOTE: do not use cross and crossX

isCoplanar :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Bool Source #

Check whether four points are coplanar

normal3 :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Maybe (Vector3 a) Source #

KEY: compute the normal of three points

vec :: Num a => Vertex3 a -> Vertex3 a -> Vector3 a Source #

Vector: p0 -> p1 = p1 - p0

ray :: Vertex3 GLfloat -> GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat Source #

KEY: Given a point and vector

  • Draw a line passes a point p₀ alone the vector v₀

r(t) = p₀ + t(p₁ - p₀)

   let p0 = Vertex3 0.0 0.0 0.0
   let v0 = Vector3 0.4 0.5 0.0
   let p1 = ray p0 1.0 v0
   drawSegmentls green [p0, p1]
   

ray2 :: GLfloat -> Vertex3 GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat Source #

KEY: Given a point and vector

  • Draw a line passes a point p₀ alone the vector v₀

r(t) = p₀ + t(p₁ - p₀)

   let p0 = Vertex3 0.0 0.0 0.0
   let v0 = Vector3 0.4 0.5 0.0
   let p1 = ray2 1.0 p0 v0
   drawSegmentls green [p0, p1]
   

perpenLine :: GLfloat -> GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> [Vertex3 GLfloat] Source #

KEY: perpendicular line to c₀ center of p₀ p₁

Given s, t, p₀ and p₁ 1. c₀ = center p₀ p₁ 2. p₁' = p₀ + s(⊥ p0 p1), p₂' = p₀ + t(⊥ p₀ p₁) 3. Draw line from p₁' to p₂'

   let vv0 = Vertex3 1   (negate 1  ) 0.0
   let vv1 = Vertex3 1.8 (negate 1.5) 0.0
   let v = [vv0, vv1]
   drawSegmentWithEndPt red v
   let vls = perpenLine 0.9 (-0.2) vv0 vv1

   drawSegmentWithEndPt green vls
   

curvePt :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> [Vertex3 GLfloat] Source #

KEY: draw curve from given function

curvePtD :: (GLdouble -> GLdouble) -> (GLdouble, GLdouble) -> [Vertex3 GLdouble] Source #

curvePtV :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Vector (Vertex3 GLfloat) Source #

drawCurve :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Color3 GLdouble -> IO () Source #

Given a function \(f\), interval \( (a, b) \)

Draw the curve on xy-plane from \(a\) to \(b\)

mapM_ (\n -> drawCurve (\x -> x^n) (-1.0, 1.0) green) [1..20]
   let f = x -> negate (x - 0.5)*(x + 0.5)
   drawCurve f (negate 1.0, 1.0) green
   

drawcurve

drawCurveList :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO () Source #

drawCurveListWithEndPt :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO () Source #

drawCurveD :: (GLdouble -> GLdouble) -> (GLdouble, GLdouble) -> Color3 GLdouble -> IO () Source #

drawCurveV :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> Color3 GLdouble -> IO () Source #

drawSurface :: (GLfloat -> GLfloat -> GLfloat) -> IO () Source #

draw Surface for equation \( f(x, y) = x^2 + y^2 \) form

Draw \( f (x, y) = x^2 + y^2 \)

drawSurface (\x y -> x^2 + y^2)

drawSurfaceR :: (GLfloat -> GLfloat -> GLfloat) -> GLfloat -> IO () Source #

draw Surface for equation \( f(x, y) = x^2 + y^2 \) form

Draw \( f (x, y) = x^2 + y^2 \)

r = 2 => 1/(r*n) 
drawSurfaceR (\x y -> x^2 + y^2) r 

plotPts :: Color3 GLdouble -> [GLfloat] -> IO () Source #

Plot all pts

Plot_Points

   plot 2d graphic

   Divide each pair of point as  (x, y, 0)

   interval from [-len2.. len2]
   let pts = [0.3, 0.4, 0.1, 0.2] 
   plotPts red pts 
   plotPts green $ quickSort1 pts
   

tangentLine :: Fractional a => (a -> a) -> (a, a) -> a -> [Vertex3 a] Source #

Draw a line that is tangent at pt (c, f(c)) where x in [x0, x1]

tangentLine

  1. Given a function f, and x0 on x-Axis
  2. Derive a tangent line at (c, f(c)) with slop = f'(c)
  3. Interpolate (x0, f(x0)) and (x1, f(x1))

interpolate' :: Fractional a => Integer -> Vertex3 a -> Vertex3 a -> [Vertex3 a] Source #

drawTangentLine :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> Color3 GLdouble -> IO () Source #

Given a function f, interval (a, b),

draw a tangent line at (x0, f(x0)) from a to b >f::x -> y

(a, b) is interval

differentiate at (x0, f x0)

normalLine :: NormalDir -> (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> [Vertex3 GLfloat] Source #

NormalDir is either counter clockwise or clockwise for normal

(x0, x1) is interval for the normal f is any function x=c is the tangent point at (c, f c)

data NormalDir = NCCW | NCW deriving (Eq)

normalLineNew :: NormalDir -> (GLfloat -> GLfloat) -> GLfloat -> GLfloat -> [Vertex3 GLfloat] Source #

drawNormalLine :: (GLfloat -> GLfloat) -> (GLfloat, GLfloat) -> GLfloat -> Color3 GLdouble -> IO () Source #

drawNormalLineNew :: (GLfloat -> GLfloat) -> GLfloat -> GLfloat -> Color3 GLdouble -> IO () Source #

cen :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat Source #

compute the center of two vertices/vertex

middle :: Floating a => Vertex3 a -> Vertex3 a -> Vertex3 a Source #

isPerpen :: Vector3 GLfloat -> Vector3 GLfloat -> Bool Source #

check two vectors whether they are perpendicular

isColinear :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

KEY: Check whether three pts are colinear in 2D plan.

NOTE

  • If two points or three points are overlapped, then they are still colinear
  • It's only for 2D plan, Vertex3 x y z ⇒ Vertex3 x y 0

NOTE: deprecated, bad name USE: isColinear2d

   f(t) = p0 + t(p1 - p0)
   f(s) = p0 + s(p2 - p0)
   f(t) = f(s) =>
   t(p1 - p0) = s(p2 - p0)
   t v1 = s v2, let A = [v1 v2]
   det A =? 0
   det A = 0 => p0 p1 p2 are colinear
   

isColinear2d :: (Num a, Eq a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

KEY: same as isColinear

NOTE: use isColinear2d, ∵ better name

isColinear3d :: Vertex3 GLdouble -> Vertex3 GLdouble -> Vertex3 GLdouble -> Bool Source #

KEY: check if three points is colinear in 3d

NOTE: use crossF product only

isInSegment :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe Bool Source #

Check whether a given point is inside the segment

NOTE use ptOnSegment instead

  • Assume three pts are different pts
  • Given p0, q0 q1, check whether p0 is inside the segment of q0 q1
  • If they are colinear
  • then check the distance \( \overline{p_0 q_0} \) \( \overline{p_0 q_1} \) and \( \overline{q_0 q_1} \)

Using following Affine combination on points formula

Linear combination on vector \( \{ x_1, x_2, \dots \} \)

\[ \begin{aligned} \sum_{i=1}^{n} \alpha_{i} x_i \end{aligned} \]

If the sum of all the coefficients is 1 \[ \begin{aligned} \sum_{i=1}^{n} \alpha_{i} &= 1 \end{aligned} \] is called Affine Combination of \( \{x_1, x_2, \dots \} \)

NOTE If we extend above definition to highter power on \(t\), \(t\) can have any power \( n > 0 \) or \( t^{n} \)

\( [(1 - t) + t]^{n} \) is just Binomial Expansion

Bezier_Curve

\[ \begin{aligned} 1 &= [(1 - t) + t]^{1} \\ Q &= (1 - t)p_0 + t p_1 \\ \\ 1 &= [(1 - t) + t]^{2} = (1 - t)^{2} + 2t(1-t) + t^2 \\ Q &= (1-t)^{2} p_0 + 2t(1-t) p_1 + t^2 p_2 \\ \end{aligned} \]

In out case, there are only two points \( p_0, p_1 \) so \( p \) is the Affine Combination of \( p_0, p_1 \) \[ \begin{aligned} p &= (1 - t) p_0 + t p_1 \\ \end{aligned} \] If \( 0 < t < 1 \) then the point on the segment \( \overline{p_0 p_1} \) but not overlapping on \( p_0, p_1 \)

If \( t = 0 \) or \( t = 1 \) then the point \(p\) is overlapping \( p_0 \) or \( p_1 \)

If \( t < 0 \) or \( t > 1 \) then the point \(p\) is NOT on the segment \( \overline{p_0 p_1} \)

p0 = Vertex3 0.5 0.5 0
q0 = Vertex3 1 1 0
q1 = Vertex3 0 0 0
isInSegment p0 q0 q1
Just True

data PtSeg Source #

Constructors

OnEndPt 
InSeg 
OutSeg 

Instances

Instances details
Eq PtSeg Source # 
Instance details

Defined in AronGraphic

Methods

(==) :: PtSeg -> PtSeg -> Bool

(/=) :: PtSeg -> PtSeg -> Bool

Show PtSeg Source # 
Instance details

Defined in AronGraphic

Methods

showsPrec :: Int -> PtSeg -> ShowS

show :: PtSeg -> String

showList :: [PtSeg] -> ShowS

ptOnSegment :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> PtSeg Source #

Better version of isInSegment

  1. If \(p_0\) is overlapped with \(q_0, q_1\) then OnPt
  2. If \(\overline{p_0 q_0} + \overline{p_0 q_1} > 0\) then OutSeg
  3. Else InSeg
   data PtSeg = OnEndPt -- ^ Overlapped pt
                | InSeg   -- ^ Inside the segment
                | OutSeg  -- ^ Out the segment
   

Maybe use better name: crossSegments - No endpt is overlapped

1. Three pts are colinear
    1. one endpts is overlapped
    2. No endpt is overlapped, one endpt is "inside" the segment
    3. Not intersected
2. Four pts are colinear
     1. No endpts is overlapped
         1. one segment "inside" the other segment
         2. one segment "outside" the other segment
     2. One endpts is overlapped
         1. one endpt is "outside" a segment
         2. one endpt is "inside" a segment
     3. two endpts are overlapped => same segment
3. No three pts are colinear
    1. If two segment is intersected, one must cross other segment
    2. Two segments DO NOT intersect

drawPrimitive :: PrimitiveMode -> Color3 GLdouble -> [(GLfloat, GLfloat, GLfloat)] -> IO () Source #

Draw primitives with a list of triple '(GLfloat, GLfloat, GLfloat)' such lines, points, lineloop etc

PrimitiveMode

   PrimitiveMode
   Lines
   LineStrip
   LineLoop
   TriangleStrip
   TriangleFan
   Quad
   QuadStrip
   Polygon
   Patches
   

drawPrimitive Lines green [(0.1, 0.2, 0.0), (0.2, 0.4, 0.0)]

drawPrimitiveVex :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

KEY: Draw primitives with a list of 'Vertex3 GLfloat'

PrimitiveMode

   PrimitiveMode
   Lines
   LineStrip
   LineLoop
   TriangleStrip
   TriangleFan
   Quad
   QuadStrip
   Polygon
   Patches


   let p0 = Vertex3 0.2 0.3 0
   let v0 = Vertex3 0   (-0.6) 0
   let v1 = Vertex3 (-0.6) (-0.6) 0
   let v2 = Vertex3 (-0.5) (-0.1) 0
   let v3 = Vertex3 0.0 0.0 0
   drawPrimitiveVex Polygon green [v0, v1, v2, v3] 

   

drawPrimitiveVex Lines green [Vertex3 0.1, 0.2, 0.0, Vertex3 0.2, 0.4, 0.0]

drawTriangleList :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

KEY: draw triangle from three vertex

  drawTriangleList red [Vertex3 0 0 0, Vertex3 1 0 0, Vertex3 0 1 0]
  

drawTriangleStrip :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

drawTriangleVex :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

KEY: Draw ONE triangle ONLY from '(Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)'

   PrimitiveMode
   Lines
   LineStrip
   LineLoop
   TriangleStrip
   TriangleFan
   Quad
   QuadStrip
   Polygon
   Patches

   let vv0 = Vertex3 0   0.6 0
   let vv1 = Vertex3 0.6 0.6 0
   let vv2 = Vertex3 0.5 0.1 0
   drawTriangleVex blue (vv0, vv1, vv2) 

   

triangle :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

KEY: Draw ONE triangle ONLY, same as drawTriangleVex

   PrimitiveMode
   Lines
   LineStrip
   LineLoop
   TriangleStrip
   TriangleFan
   Quad
   QuadStrip
   Polygon
   Patches
   

drawPrimitive' :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

draw primitive such lines, points, lineloop etc

PrimitiveMode

   Lines
   LineStrip
   LineLoop
   TriangleStrip
   TriangleFan
   Quad
   QuadStrip
   Polygon
   Patches
   

randomVertex

list <- randomVertex 60
drawPrimitive' Lines red list

drawPrimitive2 :: PrimitiveMode -> Color3 GLdouble -> [Vertex3 GLdouble] -> IO () Source #

drawPrimitiveX :: PrimitiveMode -> [Vertex3 GLdouble] -> [Color3 GLdouble] -> IO () Source #

drawLines :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

drawSegmentWithEndPt :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

Draw Segment with Two End Pts

   v = [Vertex3 0.1 0.1 0.2, Vertex3 0.4 0.2 0.7]
   drawSegmentWithEndPt red v
   
   v = [[Vertex3 0.1 0.1 0.2, Vertex3 0.4 0.2 0.7]]
   mapM_(x -> drawSegmentWithEndPt red x) vv
   

drawSegmentNoEndPt :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

drawSegmentNoEndPt2 :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO () Source #

drawFatSegmentEndPt :: GLfloat -> [Vertex3 GLfloat] -> IO () Source #

draw fat segment

   when True $ do
    let p₀ = Vertex3 0.0 0.0 0.0 :: Vertex3 GLfloat
    let p₁ = Vertex3 0.5 0.5 0.0 :: Vertex3 GLfloat
    let α = 0.005
    drawFatSegment α [p₀, p₁]
  

drawSegments :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

Draw a set segment from each pair of points(segment)

Segment contains two end points, one is begin point, other is end point

   [p0, p1, p2] = p0 -> p1    (p2 is ignored)
   [p0, p1, p2, p3]
   p0 -> p1
   p2 -> p3

   --NO loop
   drawSegments red  let v0 = Vertex3 0.1 (-0.1) 0
                         v1 = Vertex3 0.2 0.1    0
                         v2 = Vertex3 0.3 0.4    0
                         v3 = Vertex3 0.6 0.2    0
                         ls = [v0, v1, v2, v3]
                     in join $ zipWith (x y -> [x, y]) (init ls) (tail ls)

   -- Loop
   drawSegments red  let v0 = Vertex3 0.1 (-0.1) 0
                         v1 = Vertex3 0.2 0.1    0
                         v2 = Vertex3 0.3 0.4    0
                         v3 = Vertex3 0.6 0.2    0
                         ls = [v0, v1, v2, v3, v0]
                     in join $ zipWith (x y -> [x, y]) (init ls) (tail ls)
   

drawSegmentls :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

Draw one segment from p0 to p1

NOTE: deprecated * Bad name

   let p0 = Vertex3 0.1 0.1 0
   let p1 = Vertex3 0.4 0.4 0
   drawSegmentls red [p0, p1]
   

SAME: drawSegmentList

drawSegmentList :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

Draw one segment from p0 to p1

   let p0 = Vertex3 0.1 0.1 0
   let p1 = Vertex3 0.4 0.4 0
   drawSegmentList red [p0, p1]
   

SAME: drawSegment

drawSegment :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

Draw one segment from p0 to p1

   let p0 = (Vertex3 0.1 0.1 0, Vertex3 0.4 0.4 0)
   let p1 = (Vertex3 0.4 0.4 0, Vertex3 0.4 0.6 0)
   drawSegment red (p0, p1)
   

drawSegmentD :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO () Source #

Draw one segment from p0 to p1

   let p0 = (Vertex3 0.1 0.1 0, Vertex3 0.4 0.4 0)
   let p1 = (Vertex3 0.4 0.4 0, Vertex3 0.4 0.6 0)
   drawSegment red (p0, p1)
   

drawSeg :: Color3 GLdouble -> (GLdouble, GLdouble, GLdouble) -> (GLdouble, GLdouble, GLdouble) -> IO () Source #

Draw one segment from p0 to p1, simple version of drawSegmentD and drawSegment

   let p0 = (0,   0, 0)
   let p1 = (0.2, 0, 0)
   drawSeg red (p0, p1)
   

drawSegNoEnd :: Color3 GLdouble -> (GLdouble, GLdouble, GLdouble) -> (GLdouble, GLdouble, GLdouble) -> IO () Source #

drawSegmentNoEnd :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

Draw one segment with no endpt

drawSegmentNoEnd2 :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO () Source #

Draw one segment with no endpt

drawSegment' :: SegEndPt -> Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

definition: Segment contains two end points, one is begin point, other is end point [p0, p1] = p0 -> p1

data SegEndPt = No -- no pt, just a segment | End -- end pt | Beg -- begin pt | Both -- begin and end pts | Cen -- center pt | All -- all pts: begin, end and ceneter

drawSegmentArg :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> IO () Source #

Draw intersection pt from two segments | Two segments need not have an intersection.

drawSpherePt :: Vertex3 GLfloat -> GLfloat -> [Vertex3 GLfloat] Source #

draw sphere center at c with radius r

  • β is in x-y plane, it rotates around z-Axis. ϕ is in x-z plane, it rotates around y-Axis
  • \( r*\cos(ϕ) \) is the radius of circle cut through x-y plane

sphere_equation

\[ \begin{equation} \begin{aligned} f( ϕ, β ) &= r \times \cos(ϕ) * \cos(β) + x₀ \\ f( ϕ, β ) &= r \times \cos(ϕ) * \sin(β) + y₀ \\ f( ϕ, β ) &= r \times \sin(ϕ) + z₀ \end{aligned} \end{equation} \]

spherePts :: [[Vertex3 GLfloat]] Source #

KEY: points set for sphere

drawSphere :: IO () Source #

KEY: draw sphere at center

  • draw sphere at (0, 0, 0)

drawSphereN :: Int -> GLfloat -> [Color3 GLdouble] -> IO () Source #

KEY: draw sphere in n step with radius

   drawSphereN 10 0.4
  

drawPlane :: Color3 GLdouble -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> IO () Source #

draw plane with three points | no check whether they are co-linear

circlePt :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat] Source #

Generate a circle

let radius = 0.1
let pts = circlePt (Vertex3 0 0 0) radius

See circleN $n$ segments

circlePtD :: Vertex3 GLdouble -> Double -> Int -> [Vertex3 GLdouble] Source #

circle' :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat] Source #

\(\color{red}{Deprecated} \) Use circlePt

Fri Feb 15 11:13:17 2019

Draw xy-plane circle

NOTE: deprecated, Use circle'X

circle'X :: Vertex3 GLfloat -> GLfloat -> [Vertex3 GLfloat] Source #

\(\color{red}{Deprecated} \) Use circlePt

Draw xy-plane circle

KEY: draw simple circle on xy-plane

DATE: Sunday, 25 February 2024 23:09 PST

circle2 :: Vertex3 GLdouble -> Double -> [Vertex3 GLdouble] Source #

circleN :: Vertex3 GLfloat -> Double -> Integer -> [Vertex3 GLfloat] Source #

Draw xy-plane circle with $n$ segment

See circlePt at xy-plane

circleNX :: Vertex3 GLfloat -> GLfloat -> Int -> [Vertex3 GLfloat] Source #

Draw xy-plane circle with $n$ segment

See circleNX at xy-plane

vec_ :: (Fractional a, Eq a) => Vertex3 a -> Vector3 a Source #

KEY: Vector3 to Vertex3

ver_ :: (Fractional a, Eq a) => Vector3 a -> Vertex3 a Source #

KEY: Vertex3 to Vector3

drawCircleFilled :: Color3 GLdouble -> Vertex3 GLfloat -> GLfloat -> IO () Source #

Draw xy-plane circle with 10 segments

circleNArc :: Vertex3 GLdouble -> Double -> Integer -> (GLdouble, GLdouble) -> [Vertex3 GLdouble] Source #

Draw xy-plane circle with $n$ segment, draw arc, circle arc

See circlePt at xy-plane

   let cen = Vertex3 0.1 0.1 0
   let radius = 1.0
   let nStep = 10
                    + -> start interval
                    ↓
   let interval = (pi4, pi2)
                          ↑
                          + -> end interval

   circleNArc cen radius nStep interval
   
  • circleNArc center radius n_step arc=(0, pi/2)
  • Arc rotates counter-clockwise if r₁ > r₀
  • Arc rotates clockwise if r₁ <= r₀

(x - x0)^2 + (y - y0)^2 = r^2

x - x0 = r * cos α y - y0 = r * sin α

x = r * cos α + x0 y = r * sin α + y0

circleXY :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat] Source #

Draw xz-plane circle

circleXZ :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat] Source #

KEY: Draw xz-plane circle

circleYZ :: Vertex3 GLfloat -> Double -> [Vertex3 GLfloat] Source #

Draw yz-plane circle

drawDot :: Vertex3 GLfloat -> IO () Source #

KEY: draw dot, small circle

   echo dot is a circle
   r = 0.01
   c = red

   drawDot (Vertex3 0.0 0.0 0.0) -- p0
   drawDot (Vertex3 0.4 0.0 0.0) -- p1
   

drawDotX :: Color3 GLdouble -> Vertex3 GLfloat -> IO () Source #

drawDotXX :: Color3 GLdouble -> Vertex3 GLfloat -> GLfloat -> IO () Source #

drawDotR :: Vertex3 GLfloat -> Double -> IO () Source #

KEY: draw dot, small circle with radius r = 0.1

   echo dot is a circle
   r = 0.01
   c = red

   drawDot (Vertex3 0.0 0.0 0.0) -- p0
   drawDot (Vertex3 0.4 0.0 0.0) -- p1
   

drawDotColor :: Vertex3 GLfloat -> Color3 GLdouble -> IO () Source #

drawDotRColor :: Vertex3 GLfloat -> GLdouble -> Color3 GLdouble -> IO () Source #

cartToPolar :: Vector3 GLfloat -> (GLfloat, GLfloat) Source #

Given an Vector3 x y z or Vertex3 x y z | Convert Cartesian Coordinates to Polar Coordinates | beta x-y plane, | alpha x-z plane | | y z | | / | ---|/--- x | /

vecToM3x :: Vector3 GLdouble -> [[GLdouble]] Source #

vecToM3y :: Vector3 GLdouble -> [[GLdouble]] Source #

vecToM3z :: Vector3 GLdouble -> [[GLdouble]] Source #

rotx :: Floating a => a -> [[a]] Source #

right hand coordinates system in OpenGL, y-z plan, rotation matrix

  • rotate matrix on x-z plane
   rotx :: Floating a => a -> [[a]]
   rotx α =[[ 1.0,     0.0,     0.0]
           ,[ 0.0,     cos α ,  negate $ sin α]
           ,[ 0.0,     sin α,   cos α]
            ]
   

roty :: Floating a => a -> [[a]] Source #

right hand coordinates system in OpenGL, x-z plan, rotation matrix

  • rotate matrix on x-z plane
    roty :: Floating a => a -> [[a]]
    roty α =[[cos α,          0.0,  sin α]
            ,[ 0.0 ,          1.0,  0.0  ]
            ,[negate $ sin α, 0.0,  cos α]
             ]
   

rotz :: Floating a => a -> [[a]] Source #

right hand coordinates system in OpenGL, x-y plane, rotation matrix

  • rotate matrix on x-y plane
   rotz ϕ = [ [cos ϕ,   negate $ sin ϕ, 0.0]
             ,[sin ϕ,            cos ϕ, 0.0]
             ,[0.0  ,              0.0, 1.0]
             ]
   

coordTip :: Color3 GLdouble -> IO () Source #

coordTipX :: Color3 GLdouble -> GLdouble -> IO () Source #

coordTipY :: Color3 GLdouble -> GLdouble -> IO () Source #

coordTipZ :: Color3 GLdouble -> GLdouble -> IO () Source #

show3dStr :: String -> Color3 GLdouble -> GLdouble -> IO () Source #

renderCoordinates :: IO () Source #

Coordinate with tips

positive dir is the tips dir

drawCircleVec :: GLfloat -> Vertex3 GLfloat -> Vector3 GLfloat -> IO () Source #

KEY: Draw circle(r, c) which is ⊥ to ve

Given an radius r, center Vertex3 c, and Vector ve

Circle_perpendicular_a_Vector

     -- vector ve perpendicular to the circle(r, c)
     drawCircleVec 0.2 (Vertex3 0.0 0.0 0.0) (Vector3 0.2 0 0)
                    ↑           ↑                       ↑ 
                  radius r    center c             vector ve
     
   

matVx :: [[a]] -> Vertex3 a Source #

matrix to Vertex

   matVx [[x], [y], [z]] = Vertex3 x y z
   

matVe :: [[a]] -> Vector3 a Source #

matrix to Vertex

   matVe [[x], [y], [z]] = Vector3 x y z
   

veMat :: Vector3 a -> [[a]] Source #

Vector to matrix

   veMat (Vector3 x y z) = [[x], [y], [z]]
   

drawRect :: (Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

KEY: rectangle with leftTop and bottomRight

   let     x0 = -0.5::GLfloat
           y0 = -0.5::GLfloat                                                     
           z0 = 0.0::GLfloat                                                      
           x1 = 0.5::GLfloat                                                      
           y1 = 0.5::GLfloat                                                      
           z1 = 0.0::GLfloat  in drawRect ((Vertex3 x0 y0 z0), (Vertex3 x1 y1 z1))

             Y
        p₀   ↑
        ↓    |    th
        +----|----+
        |    |    |  rv
        |    |    |
   lv   |    /----- → x
        |   /     |
        +--/------+ ← p₁  
          z        

            bh   
   

http://localhost/image/opengl_draw rect.png

drawRectColor :: Color3 GLdouble -> (Vertex3 GLfloat, Vertex3 GLfloat) -> IO () Source #

KEY: draw rectangle with color (Color3 GLdouble)

drawRectColor2 :: Color3 GLdouble -> (Vertex3 GLdouble, Vertex3 GLdouble) -> IO () Source #

KEY: draw rectangle with color (Color3 GLdouble)

drawRect2d :: (GLfloat, GLfloat) -> IO () Source #

Draw Rectangle with Width and Height

          w
      ⌜--------⌝
      |        |  
      |        | 
      |   +    | h
      |        |
      |        |
      ⌞--------⌟
   

drawQuads :: [Vertex3 GLfloat] -> IO () Source #

Draw on xy-plane quads

     drawQuads [Vertex3 0.1 0.1 0.0, Vertex3 0.2 0.1 0.0, Vertex3 0.2 0.2 0.0, Vertex3 0.1 0.2 0.0]    
   

drawQuadsColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

KEY: draw quads

   drawQuadsColor red [Vertex3 0.0 0.0 0.0, Vertex3 0.2 0.0 0.0, Vertex3 0.0 0.2 0.0, Vertex3 0.0 0.0 0.2]
   

http://localhost/image/opengl_drawquads.png

drawQuadsXZColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

KEY: xz-plane draw quads

drawQuadsYZColor :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

KEY: yz-plane draw quads

drawRectFill2d :: Color3 GLdouble -> (GLfloat, GLfloat) -> IO () Source #

KEY: fill rectangle

            ↑
            |
       v0   ⟶   v1
                  
       ↑           |
       |    +      ↓  -> y

      v3    <—-    v2
   

drawRectFill2dX :: Color3 GLdouble -> (GLfloat, GLfloat) -> IO () Source #

KEY: fill rectangle

            ↑
            |
       v0   ⟶   v1

       ↑           |
       |    +      ↓  -> y

      v3    <—-    v2
   

drawHis :: [GLfloat] -> IO () Source #

KEY: draw histgram in opengl

drawHisgram :: [GLfloat] -> IO () Source #

renderText :: String -> IO () Source #

drawCircle' :: Vertex3 GLfloat -> Double -> IO () Source #

draw circle with center and radius

drawCircle cen r = drawPrimitive LineLoop red $ circle cen r

drawCircle2 :: Vertex3 GLfloat -> Double -> IO () Source #

drawCircleThreePt :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Color3 GLdouble -> IO () Source #

KEY: draw circle with three points

   let q0 = Vertex3 0 0 0
   let q1 = Vertex3 0.8 0.8 0
   let q2 = Vertex3 1.5 0.5 0
   let pt = threePtCircle q0 q1 q2
   print pt
   let c0 = case pt of
                 Just x  -> x
                 Nothing -> (Vertex3 0 0 0)
   
   -- drawCircle2 c0 $ rf $ distX c0 q1
 
   drawCircleThreePt q0 q1 q2 green

   drawSegmentWithEndPt green [q0, q1]
   drawSegmentWithEndPt blue  [q1, q2]
   

drawCircleThreePtList :: [Vertex3 GLfloat] -> Color3 GLdouble -> IO () Source #

drawCircleThreePtListX :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

threePtCircle :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat) Source #

KEY: three points fixes a circle

return: center of a circle

threePtCircleList :: [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat) Source #

center :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat Source #

KEY: Center of two Vertex3 GLfloat

drawCircleColorN :: Vertex3 GLfloat -> Double -> Color3 GLdouble -> Integer -> IO () Source #

draw circle with center and radius, n steps

   let cen = Vertex3 0.1 0.0 0.0
   let r = 0.5
   let n = 10
   drawCircleColorN cen r n
   

drawCircleXYZ :: Vertex3 GLfloat -> Double -> IO () Source #

drawCircleXYZColor :: Vertex3 GLfloat -> Double -> Color3 GLdouble -> IO () Source #

drawCircleColor :: Vertex3 GLfloat -> Color3 GLdouble -> Double -> IO () Source #

draw circle with center , Color3, radius

drawCircleColor (Vertex3 0.1 0.2 0.3) red 0.5

drawCircleColor2 :: Vertex3 GLdouble -> Color3 GLdouble -> Double -> IO () Source #

drawCircleColor' :: Color3 GLdouble -> Double -> Vertex3 GLfloat -> IO () Source #

Similar to drawCircleColor, but it can do more

  • draw two circles with different centers
mapM_ (drawCircleColor' red 0.5) [Vertex3 0.1 0.2 0.3, Vertex3 0.2 0.3 04]

conic :: [(GLfloat, GLfloat, GLfloat)] Source #

Conic Parameter Equation

gx Conic

det2 :: Num a => [[a]] -> a Source #

KEY: determinant of two dimension matrix NOTE: row as column @

det2 [[a, b], [c, d]] =>

m' =[ [a c] [b d] ]

det2(m) = a*d - c*b

@

inverseR :: [[Rational]] -> [[Rational]] Source #

inv2 :: Fractional a => [[a]] -> [[a]] Source #

Inverse of two dimension matrix

Inverse_matrix_determinant

\[ \begin{equation} \begin{aligned} A &= \begin{bmatrix} a & b \\ c & d \\ \end{bmatrix} \\ A^{ -1} &= \frac{1}{ \det A } \begin{bmatrix} d & -b \\ -c & a \\ \end{bmatrix} \end{aligned} \end{equation} \] * inverse should be used in general.

   isInver::(Fractional a, Ord a)=> [[a]] -> Bool
   isInver m = if len (filter(cx) 0 then False else True
   
  • Following function is implemented in Gaussian Elimination
  • There is some Integer overflow issue, it only works for small matrix, e.g. 10 by 10
   isInvertible::[[Integer]]->Bool
   

data SegColinear Source #

Constructors

Colinear3

If three pts are colinear => Colinear3

Colinear4

If four pts are colinear => Colinear4

None 

Instances

Instances details
Eq SegColinear Source # 
Instance details

Defined in AronGraphic

Methods

(==) :: SegColinear -> SegColinear -> Bool

(/=) :: SegColinear -> SegColinear -> Bool

Show SegColinear Source # 
Instance details

Defined in AronGraphic

Methods

showsPrec :: Int -> SegColinear -> ShowS

show :: SegColinear -> String

showList :: [SegColinear] -> ShowS

fourPtColinear :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> SegColinear Source #

If four points are colinear then return Colinear4

If only three points are colinear then return Colinear3

Else return None

data SegColinear = Colinear3 -- ^ If three pts are colinear => Colinear3
                   | Colinear4 -- ^ If four pts are colinear => Colinear4
                   | None deriving (Eq, Show) -- ^ else => None

The function uses isColinear

intersectLineTri :: (Vertex3 GLdouble, Vertex3 GLdouble) -> (Vertex3 GLdouble, Vertex3 GLdouble, Vertex3 GLdouble) -> Maybe (Vertex3 GLdouble) Source #

intersectLine :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat, [[GLfloat]]) Source #

Find the intersection of two lines, also see intersectSeg

Assume that two endpoints of each segment are not overlapped.(segment has non-zero length)

NOTE This function is ONLY for two dimensions

Line extends infinitly in both direction

  • If both line intersect at one pt => return the pt 1. Intersection can be on a segments or NOT on a segment
  • If four points are colinear: return Nothing, see fourPtColinear
   let p0 = Vertex3 0 0 0
   let p1 = Vertex3 1 0 0
   let q0 = Vertex3 1 0 0
   let q1 = Vertex3 2 0 0
   intersectLine p0 p1 q0 q1
   Nothing

   let xp0 = Vertex3 0 0    0
   let xp1 = Vertex3 1 1    0
   let xq0 = Vertex3 1 0    0
   let xq1 = Vertex3 2 (-1) 0
   let xret = intersectLine xp0 xp1 xq0 xq1
   Just (Vertex3 0.5 0.5 0) , [[0.5], [-0.5]]
   
  • Two dimensions determinant is used here
  • The Intersection of two line is NOT necessary in their segments
  • If two lines are parallel or overlapped then return Nothing
  • Else return the intersection and \( s, t \)

\[ \text{Given four pts: \(p_0, p_1\) and \(q_0, q_1\)} \\ \begin{aligned} v_0 &= p_1 - p_0 \quad v_0 \text{ is a vector} \\ v_1 &= q_1 - q_0 \quad v_1 \text{ is a vector} \\ A &= \begin{bmatrix} v_0 & v_1 \end{bmatrix} \\ \det A &= 0 \quad \text{they are linearly dependent } \end{aligned} \]

Check Line Intersection TODO: Fix ERROR on PDF: intersect_line_PDF

   data Seg a = Seg a a
   fun::Seg GLflat -> Seg GLfloat -> Maybe(Vertex3 GLfloat, [[GLfloat]])
   fun (Seg (Vertex3 x0 y0 z0) (Vertex3 x1 y1 z1)) = Nothing
   
   intersectLine p0 p1 q0 q1
   (Just ((Vertex3 2.0 2.0 0), [[2.0],[2.0]]))= intersectLine
                                               (Vertex3 0 0 0)
                                               (Vertex3 1 1 0)
                                               (Vertex3 2 0 0)
                                               (Vertex3 2 1 0)
   

intersectLine2 :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 GLfloat, (GLfloat, GLfloat)) Source #

If two line parallel or four pts colinear => return Nothing

Else there is intersection pt, pt maybe on on segment or NOT on segment

Sun Feb 17 15:32:59 2019 This function should replace intersectLine

onePtOverlappedSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat, (GLfloat, GLfloat)) Source #

Given two segments: \( (p_0, p_1), (q_0, q_1) \), find the overlapped endPt

Precondition: Four pts are NOT colinear \( \Rightarrow \) any three pts are NOT colinear

If two segments are overlapped at one endPt, return Maybe(Vertex3 GLfloat, GLfloat s, GLfloat t) else return Nothing

Four cases

  1. \( p_0 = q_0 \)
  2. \( p_0 = q_1 \)
  3. \( p_1 = q_0 \)
  4. \( p_1 = q_1 \)

onept_overlapped_segment

intersectLine' :: [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat, [[GLfloat]]) Source #

Four Vertex3 in a list

pointToLine :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat Source #

KEY: point to line, pt to line, distance from point to line in 2d

NOTE: Compute the distance from p0 to line: q0 q1

TODO: fix, the code only handles two dimension.

Given a point: p0, line: q0 q1

Compute the distance from p0 to line: q0 q1

NOTE: Use ptToLine, better function

vecToVex :: Vector3 a -> Vertex3 a Source #

KEY: vector to vertex

Vector3 to Vertex3

vexToVec :: Vertex3 a -> Vector3 a Source #

vecToList :: Vector3 a -> [a] Source #

vexToList :: Vertex3 a -> [a] Source #

listToVec :: [a] -> Vector3 a Source #

listToVex :: [a] -> Vertex3 a Source #

listToVer :: [a] -> Vertex3 a Source #

projOnPlane :: (Num a, Eq a) => Vector3 a -> (Vector3 a, Vector3 a) -> Vector3 a Source #

KEY: vector projects on plane

ptToLine3d :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat Source #

KEY: point to a line, pt to a line, distance from a pt to a line

angle2Vector :: Floating a => Vector3 a -> Vector3 a -> a Source #

KEY: angle between two `Vector3 a` `Vector3 a` RETURN: radian

DATE: Fri 8 Mar 22:51:09 2024 FIX: There is bug in the old formula to compute the angle

Change to the dot product formula ang = acos (v0 dot3ve v1) / |v0||v1|

 vx = Vertex3
 p0 = vx 1 0 0
 p1 = vx 0 0 0
 p2 = vx 0 1 0

 v10 = p1 -: p0
 v12 = p1 -: p2
 ang = angle2Vector v10 v12

 ang
 1.5707963267948966

 180/pi * ang
 90.0
 
 > vx = Vertex3
 > p0 = vx 1 0 0
 > p1 = vx 0 0 0
 > p2 = vx 1 0 0

 > v01 = p0 -: p1
 > v12 = p1 -: p2
 > angle2Vector v01 (-v12)
 0.0

 > angle2Vector v01 v12
 3.141592653589793

 > angleThreePts p0 p1 p2
 0.0
 > angleThreePts p2 p1 p0
 0.0
 

ptToLine :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat Source #

KEY: point to line, pt to line, distance from point to line in 2d

NOTE: Compute the distance from p0 to line: q0 q1

TODO: fix, the code only handles two dimension.

Given a point: p0, line: q0 q1

Compute the distance from p0 to line: q0 q1

DATE: Wednesday, 28 February 2024 00:56 PST NOTE: Use this function

intersectSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat) Source #

Find the intersection of two segments, intersectLine or intersectSegNoEndPt

Assume that two endpoints of each segment are not overlapped.(segment has non-zero length)

  • (p0, p0) is NOT a segment
  • If two EndPts from different segments are over overlapped => then Maybe(Vertex3 endpt)

NOTE This function is ONLY for two dimensions

NOTE endpoins of different segments may be coincide

   intersectSeg (p0, p1) (q0, q1)
   Nothing
   
   intersectSeg (p0, p1) (q0, q1)
   Vertex3 x y z

   v0 = Vertex3 0 0 0
   v1 = Vertex3 1 1 0
   u0 = Vertex3 1 1 0
   u1 = Vertex3 1 0 0
   intersectSeg (v0, v1) (v1, u1)
   Just (Vertex3 1.0 1.0 0.0)
   

The function is based on intersectLine * If two segments are parallel or overlapped then return Nothing

TODO: add test cases

intersectSegNoEndPt :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat) Source #

intersection excluding two EndPts, intersectLine or intersectSeg

Sun Feb 17 19:24:22 2019

There are some issues in endpts overlapped

Deprecated, Should use intersectSegNoEndPt2

If four pts are colinear \( \Rightarrow \) Nothing

intersectSegNoEndPt2 :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Maybe (Vertex3 GLfloat) Source #

intersection excluding two EndPts, intersectLine or intersectSeg

Sun Feb 17 19:26:05 2019

Fixed some bugs in intersectSegNoEndPt

   v0 = Vertex3 0 0 0
   v1 = Vertex3 1 1 0
   u0 = Vertex3 1 1 0
   u1 = Vertex3 1 0 0
   intersectSegNoEndPt2 v0 v1 v1 u1
   Nothing
   

SEE picture end_point_intersection

isIntersectedSeg :: (Vertex3 GLfloat, Vertex3 GLfloat) -> (Vertex3 GLfloat, Vertex3 GLfloat) -> Bool Source #

If four pts are colinear return False

If the intersection is within \( s \in [0.0, 1.0], t \in [0.0, 1.0] \) return True

Else return False

intersectLineR :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational, [[Rational]]) Source #

intersect line, return Rational

threePtDeterminant :: Fractional a => Vertex3 a -> Vertex3 a -> Vertex3 a -> a Source #

Three points rotation order can be determinated by the \( \color{red}{\text{Right Hand Rule}} \)

Three_Points_Direction

If given three points in following order:

p₀ = (1, 0)

p₁ = (0, 0)

p₂ = (0, 1)

then vectors are computed in following:

v10 = p₀ - p₁

v12 = p₂ - p₁

matrix can be formed as following:

m = [v10, v12]

\( \vec{v_{01}} \times \vec{v_{02}} \) in Right Hand Rule

\[ m = \begin{bmatrix} 1 & 0 \\ 0 & 1 \\ \end{bmatrix} \\ \det m = 1 > 0 \\ \]

If the three points are collinear:

\( \det M = 0 \)

If the order of three points in clockwise order:

\( \det M > 0 \)

If the order of three points in counter clockwise order:

\( \det M < 0 \)

Sunday, 14 April 2024 14:50 PDT
FIXME: there is bug in the cod
       v10 = v2m $ p0 -: p1
       v10 = v2m $ p1 -: p0 ?

threePtCCW :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

Three points in Counter ClockWise order

\( \det M > 0 \)

threePtCW :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

Three points in ClockWise order

\( \det M < 0 \)

threePtCollinear :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

Three points are collinear

\[ \begin{aligned} p_0 &= (x_0, y_0) \\ p_1 &= (x_1, y_1) \\ p_2 &= (x_2, y_2) \\ u &= p_0 - p_1 \\ u &= (x_0 - x_1, y_0 - y_1) \\ v &= p_2 - p_1 \\ v &= (x_2 - x_1, y_2 - y_1) \\ M &= \begin{bmatrix} u & v \end{bmatrix} \\ &\mbox{If three pts are colinear, then } \\ \det M &= 0 \\ \end{aligned} \]

ptOnLeftLine :: (Fractional a, Ord a) => Vertex3 a -> Vertex3 a -> Vertex3 a -> Bool Source #

Given a point \( p_0 \), a line \(q_0, q_2 \) === Check whether a point \(p_0\) is on the left size of a line \( q_0, q_2 \), it is based on threePtDeterminant with additional condtion: \(y_2 > y_0 \) or \( y_2 < y_0 \) since

NOTE y2 \(\neq\) y0 where given (Vertex3 x0 y0 z0) and (Vertex3 x2 y2 z2)

Assume \( p_0, p_2 \) are not coincide

  • If pt on the line, return False
  • If pt on the right side of the line, return False
  • Else return True

\[ \begin{aligned} p_1 &= (x_1, y_1) \\ p_0 &= (x_0, y_0) \\ p_2 &= (x_2, y_2) \\ u &= \overrightarrow{p1 p0} \\ v &= \overrightarrow{p1 p2} \\ \end{aligned} \]

if \( y_2 > y_0 \) form a determinant \[ \begin{aligned} \det \begin{vmatrix} u & v \end{vmatrix} > 0 \end{aligned} \] if \( y_2 < y_0 \) form a determinant \[ \begin{aligned} \det \begin{vmatrix} u & v \end{vmatrix} < 0 \end{aligned} \]

If \( y_2 = y_0 \), compare \( x_0, x_2 \)

Check whether a point is below a line \(p_0, p_2\)

if \( x_2 < x_0 \) \[ \begin{aligned} \det \begin{vmatrix} u & v \end{vmatrix} > 0 \end{aligned} \]

if \( x_2 > x_0 \) \[ \begin{aligned} \det \begin{vmatrix} u & v \end{vmatrix} < 0 \end{aligned} \]

ptInsideTri :: (Floating a, Ord a) => Vertex3 a -> (Vertex3 a, Vertex3 a, Vertex3 a) -> (Bool, a) Source #

KEY: Check whether a point \(p_0\) is inside a triangle \( \triangle ABC \), point is inside triangle

  • is a point inside a triangle
  • NOTE the order of three pts: \(A, B, C\) does't matter. e.g CCW or CW
  • \(p_0\) can NOT be the same point as \(A, B, C\), if \(p_0\) is overlapped pts \(A, B, C\), then return (False, 0.0)
  • If \(p_0\) is collinear with AB, BC, or AC, then \(p_0\) is considered inside the \( \triangle ABC \)

\(p_0\) is the point that is tested three points \(A, B, C\) forms a triangle

  • if point p0 inside the triangle, return true
  • The sum of three angles are in degree.
 let p0 = Vertex3 0.1 0.1 0
 let a  = Vertex3 1 0 0
 let b  = Vertex3 0 0 0
 let c  = Vertex3 0 1 0
 
 ptInsideTri p0 (a, b, c)
 (True, 360.0)
 

TODO: how to check whether a pt is inside a n-polygon ptInsidePolygon N-Polygon

DATE: Tue 12 Mar 01:01:02 2024 FIX: fixed a serious bug when two different types are mixed NOTE: Floating a => Vertex3 a and Vertex3 GLfloat

DATE: Mon 18 Mar 11:59:21 2024 UPDATE: if the vertex is same as one of triangle vertexes, then the vertex is INSIDE the triangle

isPtInsideTri :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat) Source #

KEY: same as ptInsideTri is a point inside a triangle

  • Better name

DATE: Mon 18 Mar 14:56:10 2024 NOTE: deprecated NOTE: Does not support Float and Double NOTE: use ptInsideTri

isPtInsideTriList :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> (Bool, GLfloat) Source #

KEY: almost same as ptInsideTri is a point inside a triangle

  • Pass a list of vertex (three)
  • Better name

perpPlane :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational) Source #

  • KEY: distance to plane, pt to plane, point to three points
  • Given a point p0 and three pts: q0, q1, q2,

Compute the intersection of line is perpendicular to the plane and passes point p0

If three pts (q0, q1, q2) are colinear, return Nothing

otherwise, return Just (Vertex3 GLfloat)

NOTE: the function does not work in 3d

lineIntersectPlane :: Vertex3 GLfloat -> Vector3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> Maybe (Vertex3 Rational) Source #

Line intersects Plane | Given Line: p0 p1 and Plane: q0 q1 q2 | Compute the intersection of line and plane | p1 = p0 +: h(p1 -: p0)

convexHull :: Int -> [Vertex3 GLfloat] -> [[Vertex3 GLfloat]] Source #

Slow Algorithm 1 \( \color{red}{ \mathcal{O}(n^2)} \)

  1. find the a point \( p_0 \) which has the maximum y-axis value
  2. find the a point \( p' \) from \( p_0 \) so that the rest of all the points on one side of the segment \( \overline{p_0 p'} \)
  3. continua with the rest of points

Slow_Algorithm

p0 p1 p2 p3
(p0, p1) (p0, p2) (p0, p3)
(p1, p2) (p1, p3)
(p2, p3)

Naive Algorithm to compute the convex hull in \( \color{red}{\mathcal{O}(nh)} \) where \( \color{red}{n} \) is the number of points on the plane, \( \color{red}{h} \) is the number of points on the convex hull

If all the points are around the convex hull, then the runtime will be \( \color{red}{\mathcal{O}(n^2)} \)

convexHull n pts
n is the total of vertices
pts contains all the vertexes

p0 = Vertex3 0 0 0
p1 = Vertex3 1 0 0
p2 = Vertex3 0 1 0
p3 = Vertex3 0.1 0.1 0
pts= [p0, p1, p2, p3]
n  = 4 = len pts
pts = [p0, p1, p2, p3]
exp= [[p2, p1],
      [p1, p0],
      [p0, p2]]
  • Algorithm ConvexHull
  • Find a top vertex: B(Vertex3 x y z) with maximum y-Axis value (TODO: What if there are more than one pts on the top?)
  • Construct a new vertex: A(Vertex3 x+1 y z) from top(Vertex3 x y z)
  • Compute \( \cos ∠ABC \) from three points: \(A, B, C\)
  • If there are only two points in pts for the list of Vertex3 e.g. p0 p1
  • then segments: \(\overline{AB} \) and \(\overline{BC} \) are drawn Three_pts_angle

n = length pts \(\Rightarrow\) n vertices \(\Rightarrow\) n edges. if there is two vertices, then \((p_0, p_1)\) and \((p_1, p_0)\)

vec(top x1) and vec(top x2)

\(\vec{v_1}\) = top -> x1 = x1 -: top

\(\vec{v_2}\) = top -> x2 = x2 -: top

  • TODO: Handle the case where the three points are colinear.
  • TODO: If there are more than one point that have maximum y-axis, then choose the left most point Top_Point

\( \color{red}{TODO} \): use eliminate points technic to improve the algorithm Eliminate_Points

It seems that the algorithm is still \( \color{red}{ \mathcal{O}(nh)} \) Given n vertices on a plane. There are \(h\) points on the convex hull. Assume \( \frac{1}{h} n \) vertices may be eliminated when the next point is found on the convex hull. The total number of steps are: \[ \begin{aligned} s &= n + \frac{h-1}{h} n + \frac{h-2}{h} n + \dots + \frac{1}{h} n \\ s &= n h (1 + 2 + 3 + \dots + h) \\ s &= n h \frac{(1 + h)h}{2} \\ s &= n \frac{1+ h}{2} \\ &= \mathcal{O}(nh) \\ \end{aligned} \]

When the algo walks around the convex hull in counter clokcwise order.

segment can be drawn from top point to previous point

All the points can be removed if they are on the left side of the segment

\( \color{red}{TODO} \) use other algo: check whether a point is on the left or right side of a segment

The algo can be check with the determinant of two vectors threePtDeterminant Three_Points_Direction

Monday, 26 February 2024 16:51 PST NOTE: DO NOT USE IT, deprecated NOTE: Delete it, there is bug USE: convexHull4X

convexHull2 :: Int -> [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

Same as convexHull, except that it return [(Vertex3 GLfloat, Vertex3 GLfloat)]

Monday, 26 February 2024 16:51 PST NOTE: DO NOT USE, deprecated NOTE: There is bug on it, Delete it Use convexHull4X

convexHullAllSeg :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

Connect all pts inside convex hull without crossing intersection

All_Segments_ConvexHull

   let vexList = [Vertex3 0.1 0.1 0.1, Vertex3 0.4 0.3 0.6, Vertex3 0.6 0.8 0.2]
   mapM_(vx -> do 
               drawSegment green vx 
               threadDelay 500
               ) $ convexHullAllSeg vexList



   Wednesday, 29 June 2022 02:22 PDT
   BUG:

       cx = [
               Vertex3 0.1   0.1  0
              ,Vertex3 0.2   0.6  0
              ,Vertex3 0.88  0.9  0
              ,Vertex3 0.25  0.34 0
              ,Vertex3 0.12  0.8  0
              ,Vertex3 1.3   0.12 0
             ]

       let lsx = convexHullAllSeg cx

       OUTPUT: lsx
      (Vertex3 0.1 0.1 0.0,Vertex3 0.2 0.6 0.0)
      (Vertex3 0.1 0.1 0.0,Vertex3 0.25 0.34 0.0)
      (Vertex3 0.12 0.8 0.0,Vertex3 0.1 0.1 0.0)
      (Vertex3 0.12 0.8 0.0,Vertex3 0.2 0.6 0.0)
      (Vertex3 0.12 0.8 0.0,Vertex3 0.88 0.9 0.0)
      (Vertex3 0.12 0.8 0.0,Vertex3 1.3 0.12 0.0)

      (Vertex3 0.12 0.8 0.0,Vertex3 1.3 0.12 0.0)
      (Vertex3 0.12 0.8 0.0,Vertex3 1.3 0.12 0.0)

      (Vertex3 0.2 0.6 0.0,Vertex3 0.25 0.34 0.0)

      (Vertex3 0.88 0.9 0.0,Vertex3 0.88 0.9 0.0)  <- Same Vertex

      (Vertex3 1.3 0.12 0.0,Vertex3 0.1 0.1 0.0)
      (Vertex3 1.3 0.12 0.0,Vertex3 0.12 0.8 0.0)
      (Vertex3 1.3 0.12 0.0,Vertex3 0.12 0.8 0.0)
      (Vertex3 1.3 0.12 0.0,Vertex3 0.12 0.8 0.0)
      (Vertex3 1.3 0.12 0.0,Vertex3 0.2 0.6 0.0)
      (Vertex3 1.3 0.12 0.0,Vertex3 0.25 0.34 0.0)

      (Vertex3 1.3 0.12 0.0,Vertex3 0.88 0.9 0.0)  <- Duplicated segments
      (Vertex3 1.3 0.12 0.0,Vertex3 0.88 0.9 0.0)  <- 
   

convexHull3

vertexWithAllTri :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Vertex3 GLfloat -> [[Vertex3 GLfloat]] Source #

Given a Triangle mesh with all segments and a vertex, return a list of triangles

meshAllTriangle :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [Vertex3 GLfloat] -> [[Vertex3 GLfloat]] Source #

KEY: find all triangles from a set of vertexes and segments

Assume any three pts forms a triangle without intersection.

drawTriangulation :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> (GLfloat, GLfloat) -> IO () Source #

KEY: triangulation, triangulate

  • Given a set of vertexes and a list of segments
  • Triangulate the mesh and generate a set of segments.
  • Very slow version, 100 vertexes, it takes 12.647 seconds to triangulate the mesh.

Triangulation

drawTriangulationWithCircle :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> (GLfloat, GLfloat) -> IO () Source #

KEY: triangulation, triangulate

  • Given a set of vertexes and a list of segments
  • Triangulate the mesh and generate a set of segments.
  • Very slow version, 100 vertexes, it takes 12.647 seconds to triangulate the mesh.

Triangulation

collectSegment :: [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

triangulateSimple :: [Vertex3 GLfloat] -> [Vertex3 GLfloat] -> [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))] -> [(Bool, (Vertex3 GLfloat, Vertex3 GLfloat))] Source #

lsToTup2 :: [Vertex3 GLfloat] -> (Vertex3 GLfloat, Vertex3 GLfloat) Source #

lsToTup3 :: [Vertex3 GLfloat] -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) Source #

tupTols3 :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> [Vertex3 GLfloat] Source #

tupTols2 :: (Vertex3 GLfloat, Vertex3 GLfloat) -> [Vertex3 GLfloat] Source #

flipEdge :: Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Maybe ((Vertex3 GLfloat, Vertex3 GLfloat), (Vertex3 GLfloat, Vertex3 GLfloat), [(Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat)]) Source #

KEY:

  1. Given a vertex and a list of triangles.
  2. If the vertex is inside the inscribe circle in the triangle.
  3. Remove a segment and add a segment, add two triangles

isPtOnInscribeCircle :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat) Source #

isPtInsideInscribeCircle :: Vertex3 GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> (Bool, GLfloat) Source #

intersectSegNoEndPt3 :: [Vertex3 GLfloat] -> [Vertex3 GLfloat] -> Maybe (Vertex3 GLfloat) Source #

cmpVex :: Vertex3 GLfloat -> Vertex3 GLfloat -> Bool Source #

sortVex :: [[Vertex3 GLfloat]] -> [[Vertex3 GLfloat]] Source #

sortVexL :: [Vertex3 GLfloat] -> [Vertex3 GLfloat] Source #

intersectSegNoEndPtList :: (Vertex3 GLfloat, Vertex3 GLfloat) -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [Maybe (Vertex3 GLfloat, (Vertex3 GLfloat, Vertex3 GLfloat))] Source #

Given a segment, a list of segments if a intersection is found, then return the vertex of intersection and the segment

convexHull3 :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

KEY: convexhull, convex hull

  • Monday, 26 February 2024 16:55 PST
  • TODO: How to handle the boundary pts are colinear, DONE

covexhull_best

  • NOTE: Does not allow duplicated vertex, vertices, vertexes
  • NOTE: Use convexHull4X

convexHull4X :: [Vertex3 GLfloat] -> Bool -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

KEY: draw convexhull or draw spiral

DATE: Monday, 26 February 2024 16:33 PST

NOTE: At least two vertex vertices vertexes

 -- Draw convexHull
 let ls = [Vertex3 0 0 0, Vertex3 0.5 0 0, Vertex3 0 0.5 0, Vertex3 0.2 0.2]
 let isConvexHull = True
 let lt = convexHull4X ls isConvexHull
 mapM_ (drawSegment red) lt
 mapM_ (drawDot green) ls

 -- Draw spiral
 let isConvexHull = False
 let lt = convexHull4X ls isConvexHull
 

convexHullLoop :: [Vertex3 GLfloat] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

KEY: convexhull, loop all the outer boundary to inner boundary

NOTE: See convexHull4 spiral

convexhullloop

shiftX :: Floating a => Vertex3 a -> a -> Vertex3 a Source #

shiftXList :: Floating a => [Vertex3 a] -> a -> [Vertex3 a] Source #

shiftY :: Num a => Vertex3 a -> a -> Vertex3 a Source #

shiftYList :: Num a => [Vertex3 a] -> a -> [Vertex3 a] Source #

shiftXY :: Num a => (a, a) -> Vertex3 a -> Vertex3 a Source #

shiftXYList :: Num a => (a, a) -> [Vertex3 a] -> [Vertex3 a] Source #

shiftTriX :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) Source #

shiftTriY :: (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) -> GLfloat -> (Vertex3 GLfloat, Vertex3 GLfloat, Vertex3 GLfloat) Source #

ptInsidePolygon :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> Bool Source #

Check whether a pt is inside a polygon (assume the polygon is convex)

This is essentially a Covex Hull problem => use Convex Hull Algorithm

TODO: Add test cases, never test it yet

   let p  = Vertex3 0.2 0.3 0
   let v0 = Vertex3 0   0.6 0
   let v1 = Vertex3 0.6 0.6 0
   let v2 = Vertex3 0.0 0.0 0
   ptInsidePolygon p [v0, v1, v2]  -- return True 
   

containPt :: Vertex3 GLfloat -> [Vertex3 GLfloat] -> Bool Source #

Given a \(p_0\): Vertex3 and [Vertex3], check whether the list contain p0

projv :: Fractional a => Vector3 a -> Vector3 a -> Vector3 a Source #

Projection from \(u\) onto \(v\) in Vector3

projection

perpPlaneX :: (Fractional a, Eq a) => Vertex3 a -> (Vertex3 a, Vertex3 a, Vertex3 a) -> Vertex3 a Source #

NOTE: q0 q1 q3 should be in CW

q0 / | / | / | / q2 ---------- q1

v10 x v12

nr :: Floating a => Vector3 a -> a Source #

Compute the norm of a vector, length of a vector

\(v = (x, y, z)\)

\(|v| = \sqrt{ x^2 + y^2 + z^2} \)

uv :: Floating a => Vector3 a -> Vector3 a Source #

KEY: Normalize a vector, norm of a vector

e.g \( \|\vec{v}\| = 1 \)

normalizeV3 :: Floating a => Vector3 a -> Vector3 a Source #

rod :: (Eq a, Floating a) => Vector3 a -> Vector3 a -> a -> Vector3 a Source #

Rodrigue formula

\(u\) rotates around \(v\) in angle \(\phi\) in right hand rule

rejection = \(u - p\)

gx Rotation

cosVex3 :: Floating a => Vertex3 a -> Vertex3 a -> Vertex3 a -> a Source #

KEY: Compute an angle from three points

  • Three points: \(a, b, c \) in angle \(\angle ABC \) with dot product
let a = Vertex3 1 0 0
let b = Vertex3 0 0 0
let c = Vertex3 0 1 0
cosVex3 a b c
0.0
          ∠ ABC
          B --------A
          |
          |
          |
          C
   

\[ \begin{equation} \begin{aligned} \vec{ba} &= a - b \\ \vec{bc} &= c - b \\ \vec{ba} \circ \vec{bc} &= | \vec{ba} | | \vec{bc} | \cos{\angle ABC} \\ \cos{\angle ABC} &= \frac{ \vec{bc} \circ \vec{bc} }{| \vec{ba} | | \vec{bc}|} \\ \end{aligned} \end{equation} \]

angleThreePts :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat Source #

Compute an angle from three points: \(a, b, c \) with dot product

  • The angle is defined by angle $angle ABC$ in $bigtriangleup ABC$ from point $a$ to $c$ in counter-clockwise
let a = Vertex3 1 0 0
let b = Vertex3 0 0 0
let c = Vertex3 1 0 0
angleThreePts a b c
0.0
   vx = Vertex3
   p0 = vx 1 0 0
   p1 = vx 0 0 0
   p2 = vx 0 1 0

   v10 = p1 -: p0
   v12 = p1 -: p2

   a = angle3Pts p0 p1 p2
   180/pi * a
   
     interval of angle is [0, π]
   

angle3Pts :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> GLfloat Source #

Compute an angle from three points: \(a, b, c \) with dot product

  • The angle is defined by angle $angle ABC$ in $bigtriangleup ABC$ from point $a$ to $c$ in counter-clockwise
let a = Vertex3 1 0 0
let b = Vertex3 0 0 0
let c = Vertex3 1 0 0
angleThreePts a b c
0.0
   vx = Vertex3
   p0 = vx 1 0 0
   p1 = vx 0 0 0
   p2 = vx 0 1 0

   v10 = p1 -: p0
   v12 = p1 -: p2

   a = angle3Pts p0 p1 p2
   180/pi * a
   
     interval of angle is [0, π]
   

nonCrossSegmentNoEndPt :: [(Vertex3 GLfloat, Vertex3 GLfloat)] -> Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

Find all the segments DO NOT Cross some new segments

Current algorithm is brute force

NOTE use Convex Hull algo might be faster

NOTE EndPts are excluded, please see intersectSegNoEndPt

  • Given a list of segments and a point
  • _SEE_ pictures to better understand it non_cross_segment

non_cross_segment_2

Given Segments \( [(B, E), (E, A), (A, D), (D, C)] \) pt: \(F\)

return => \( [(A, F), (F, D), (F, C)] \)

   let p0 = Vertex3 0 0 0
       p1 = Vertex3 0.5 0 0
       p2 = Vertex3 0 0.5 0
       q0 = Vertex3 1 1 0
       ls = [(p0, p1), (p0, p2)]
       exp= sort [(p0, q0), (p1, q0), (p2, q0)]
       in exp == (sort $ nonCrossSegmentNoEndPt ls q0)

   let p0 = Vertex3 0 0 0
       p1 = Vertex3 0.5 0 0
       p2 = Vertex3 0 0.5 0
       q0 = Vertex3 1 1 0
       ls = [(p0, p1), (p1, p2)]
       exp= sort [(p1, q0), (p2, q0)]
       in exp == (sort $ nonCrossSegmentNoEndPt ls q0)
   

remove all the segments with same vertex from old segments list then check all the new segments with the rest of old segments list

rmAdjacentSeg :: Vertex3 GLfloat -> [(Vertex3 GLfloat, Vertex3 GLfloat)] -> [(Vertex3 GLfloat, Vertex3 GLfloat)] Source #

Remove all adjacent edges or adjacent segments from a list of segments/edges

affineTri :: Vertex3 GLfloat -> Vertex3 GLfloat -> Vertex3 GLfloat -> [Vertex3 GLfloat] Source #

Affine Combination on three points

Draw all the points inside a triangle p0 p1 p2

The number of steps is \( n = 10 \)

Extend it to polygon

Affine_Triangle

drawSegmentFromTo :: Color3 GLdouble -> [Vertex3 GLfloat] -> IO () Source #

Draw all segments from Vertex3 a To Vertex3 b

drawSegmentFromTo2 :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO () Source #

Draw all segments from Vertex3 a To Vertex3 b

Deprecated Use drawSegmentFromToD

drawSegmentFromToD :: Color3 GLdouble -> [Vertex3 GLdouble] -> IO () Source #

Draw all segments from Vertex3 GLdouble To Vertex3 GLdouble

grid :: [[Vertex3 GLfloat]] Source #

2d grid on x-y-plane, z=0

draw grid

mapM_ (\row -> drawSegmentFromTo red row ) grid 
mapM_ (\row -> drawSegmentFromTo red row ) $ tran grid 

grid2 :: (GLfloat -> GLfloat -> GLfloat) -> [[Vertex3 GLfloat]] Source #

grid3 :: (GLfloat -> GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> [[Vertex3 GLfloat]] Source #

Draw parameter equation.

x = 2*u u -> 2*u u [1..10] y = 3*v v -> 3*v v [3..20] z = u + v (u, v) -> u + v

drawParamSurf :: (GLfloat -> GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> (GLfloat -> GLfloat) -> IO () Source #

torus2 :: [[Vertex3 GLfloat]] Source #

 torus2::[(GLfloat, GLfloat, GLfloat)]
 torus2= [ ( fx i k, 
            fy i k, 
            fz i k ) | i <- [1..n], k <-[1..n]]
         where 
             del = rf(2*pi/(n-1))
             n = 100 
             r = 0.2
             br = 0.3

             fx = i k -> (br + r**cos(del*i))*cos(del*j)
             fy = i k -> sin(rf del*i)
             fz = i k -> (br + r*cos(rf del*i))*sin(rf del*j)

   i = [1..n], j = [1..n]
   x = outer + inner × cos(δ × i) × cos(δ × j)
   y = sin(δ × i)
   z = outer + inner × cos(δ × i) × sin(δ × j)
 

Torus equation http://localhost/html/indexThebeautyofTorus.html

drawTorus :: GLfloat -> GLfloat -> Int -> [Color3 GLdouble] -> IO () Source #

type Fx = Int -> Int -> GLfloat Source #

type Fy = Int -> Int -> GLfloat Source #

type Fz = Int -> Int -> GLfloat Source #

type Fx' = Int -> Int -> GLdouble Source #

type Fy' = Int -> Int -> GLdouble Source #

type Fz' = Int -> Int -> GLdouble Source #

drawParamSurface :: Fx -> Fy -> Fz -> IO () Source #

drawParamSurfaceN :: Fx -> Fy -> Fz -> Int -> IO () Source #

draw parametric surface

   See $sp/PlotGeometry

   -- draw s sphere
   let n = 40::Int
       δ = 2*pi/ rf(n-1) :: GLfloat
       r = 0.4
       br = 0.2
       σ = 1/ rf(n-1)

       fx::Int -> Int -> GLfloat
       fx i j = let i' = rf i
                    j' = rf j
                    α  = δ*i'
                    β  = δ*j'
                in r * cos β * cos α
       fy::Int -> Int -> GLfloat
       fy i j = let i' = rf i
                    j' = rf j
                    α  = δ*i'
                    β  = δ*j'
                in r * cos β * sin α

       fz::Int -> Int -> GLfloat
       fz i j = let i' = rf i
                    j' = rf j
                    α  = δ*i'
                    β  = δ*j'
                in r * sin β
       in drawParamSurfaceN fx fy fz n
   

combinePt :: Num a => [[Vertex3 a]] -> [Color3 GLdouble] -> [[(Color3 GLdouble, Vertex3 a)]] Source #

drawParamSphere :: Fx -> Fy -> Fz -> Int -> [Color3 GLdouble] -> IO () Source #

drawCubeQuadX :: Vertex3 GLdouble -> GLdouble -> IO () Source #

drawCubeQuadT :: (GLdouble, Vertex3 GLdouble) -> IO () Source #

drawCubeQuad :: GLfloat -> IO () Source #

  • - |
  • - -
  • - KEY: draw cube with quad
  • - @
  • - @

drawCubeQuadD :: GLdouble -> IO () Source #

geneParamSurface :: Fx -> Fy -> Fz -> Int -> [[Vertex3 GLfloat]] Source #

KEY: generate parametric surface points

   type Fx = Int -> Int -> GLfloat
   type Fy = Int -> Int -> GLfloat
   type Fz = Int -> Int -> GLfloat
   

drawSurfaceFromList :: [[Vertex3 GLfloat]] -> IO () Source #

KEY: draw surface from list of [Vertex3 GLfloat]

grid2Ratio :: (GLfloat -> GLfloat -> GLfloat) -> GLfloat -> [[Vertex3 GLfloat]] Source #

grid 2d with ratio:

r = 1  => 1/(r*n) => 1/n
r = 2  => 1/(2*n) 

list3ToVertex3 :: Show a => [a] -> Vertex3 a Source #

KEY: list to Vertex3, list to Vertex3

[1, 2, 3] => (1, 2, 3)

vertex3ToList :: Vertex3 a -> [a] Source #

Vertex3 to list

(1, 2, 3) => [1, 2, 3]

readGLScript :: FilePath -> IO [String] Source #

KEY: read file to load geometry(ies), read script

  1. "--" will be ignored
  2. Emtpy line will be ignored

Support following geometries so far

     point
     0.1 0.1 0
     0.2 0.2 0
     0.3 0.3 0
     endpoint

     segment
     0.1 0.1 0.1
     0.2 0.2 0.2
     0.3 0.3 0.3
     0.4 0.4 0.4
     endsegment

     triangle
     0.1 0.1 0.1
     0.2 0.2 0.2
     0.3 0.3 0.3
     0.4 0.4 0.4
     0.5 5.5 0.5
     0.6 0.6 0.6
     endtriangle
   

strToVector3 :: String -> Vector3 GLdouble Source #

string to vector3

strToTriple :: String -> (GLfloat, GLfloat, GLfloat) Source #

KEY: str to triple, string to triple

   String to (GLfloat, GLfloat, GLfloat)
   

vertex3ToTriple :: Vertex3 GLfloat -> (GLfloat, GLfloat, GLfloat) Source #

KEY:

tripleToVertex3 :: (GLfloat, GLfloat, GLfloat) -> Vertex3 GLfloat Source #

KEY:

strToVertex3 :: String -> Vertex3 GLfloat Source #

KEY:

strToVertex3' :: String -> Vertex3 GLdouble Source #

KEY:

takeVertex3 :: [String] -> [Vertex3 GLdouble] Source #

drawComplex :: (Complex GLfloat -> Complex GLfloat) -> GLfloat -> IO () Source #

KEY: Draw complex function

                   + Complex function, id => ([-1, 1], [-1, 1]) Grid
                   |
   drawComplex (c -> c * c) 0.8
                              |
                              + -> Scale image, 1.0 => x = [-1, -1 + 0.1 .. 1]
                                                       y = [-1, -1 + 0.1 .. 1]
   
  

Orphan instances

Num a => Num (Vector3 a) Source #

num instance for Vector3

Instance details

Methods

(+) :: Vector3 a -> Vector3 a -> Vector3 a

(-) :: Vector3 a -> Vector3 a -> Vector3 a

(*) :: Vector3 a -> Vector3 a -> Vector3 a

negate :: Vector3 a -> Vector3 a

abs :: Vector3 a -> Vector3 a

signum :: Vector3 a -> Vector3 a

fromInteger :: Integer -> Vector3 a

Num a => Num (Vertex3 a) Source #

num instance for Vertex3

Instance details

Methods

(+) :: Vertex3 a -> Vertex3 a -> Vertex3 a

(-) :: Vertex3 a -> Vertex3 a -> Vertex3 a

(*) :: Vertex3 a -> Vertex3 a -> Vertex3 a

negate :: Vertex3 a -> Vertex3 a

abs :: Vertex3 a -> Vertex3 a

signum :: Vertex3 a -> Vertex3 a

fromInteger :: Integer -> Vertex3 a