on master help sign in
draw 3D relation graphs using vectors
commitd513b2e403b93acb512a46b2d0023095b1c60edf authorAgentM <agentm@themactionfaction.com> dateTue 23 Jun 2015, 12:50 (11 years ago) parent82a6791
2 files changed+8−4
ProjectM36/Relation/Show/Gnuplot.hs+6−3 TutorialD/Interpreter/RODatabaseContextOperator.hs+2−1
ProjectM36/Relation/Show/Gnuplot.hs+6−3
@@ -35,8 +35,11 @@ points2DRelation rel = relFold folder [] rel
3535 where
3636 folder tup acc = (intFromAtomIndex 0 tup, intFromAtomIndex 1 tup) : acc
3737
38−graph3DRelation :: Relation -> Graph3D Double Double Double
39−graph3DRelation rel = Data3D [Title "rel"] [StepX 1.0, StepY 1.0] $ map (\(x,y,z) -> (fromIntegral x, fromIntegral y, fromIntegral z)) $ points3DRelation rel
38+graph3DRelation :: Relation -> [Graph3D Double Double Double]
39+graph3DRelation rel = map lineGraph $ points3DRelation rel
40+ where
41+ lineGraph (x,y,z) = Data3D [Title "rel", Style Lines] [StepX 1.0, StepY 1.0] $ [(fromIntegral x, fromIntegral y, fromIntegral z),
42+ (fromIntegral x, 0, 0)]
4043
4144points3DRelation :: Relation -> [(Int, Int, Int)]
4245points3DRelation rel = relFold folder [] rel
@@ -60,7 +63,7 @@ sample3dRelation = case mkRelationFromList (A.attributesFromList [Attribute "x"
6063type G2D = Graph2D Double Double
6164type G3D = Graph3D Double Double Double
6265
63−plotRelation :: Relation -> Either PlotError (Either G2D G3D)
66+plotRelation :: Relation -> Either PlotError (Either G2D [G3D])
6467plotRelation rel = let attrTypes = V.replicate (arity rel) IntAtomType in
6568 if attrTypes /= A.atomTypes (attributes rel) then
6669 Left InvalidAttributeTypeError
TutorialD/Interpreter/RODatabaseContextOperator.hs+2−1
@@ -80,7 +80,8 @@ evalRODatabaseContextOp context (ShowRelation expr) = do
8080
8181evalRODatabaseContextOp context (PlotRelation expr) = case runState (evalRelationalExpr expr) context of
8282 (Left err, _) -> DisplayErrorResult $ T.pack (show err)
83− (Right rel, _) -> DisplayIOResult $ showPlottedRelation rel
83+--(Right rel, _) -> DisplayIOResult $ showPlottedRelation rel
84+ (Right rel, _) -> DisplayIOResult $ savePlottedRelation "/tmp/graph.png" rel
8485
8586evalRODatabaseContextOp context (ShowConstraint name) =
8687 case name of