From 58bbfc54e80c5c4de8f79fb3fc5c4c76d190ccd0 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 24 May 2024 23:49:17 +0800 Subject: [PATCH] (ADD) Point, Line, Rect --- .gitignore | 4 +++ Component/Geometric/geometry.h | 45 ++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 Component/Geometric/geometry.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ed07c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +vscGetReady.sh +*~ +main +test.sh diff --git a/Component/Geometric/geometry.h b/Component/Geometric/geometry.h new file mode 100644 index 0000000..65c254d --- /dev/null +++ b/Component/Geometric/geometry.h @@ -0,0 +1,45 @@ +#ifndef CYBERSIGHT_GEOMETRY_H +# define CYBERSIGHT_GEOMETRY_H + +# include + +typedef struct { + int x; + int y; +} Point; + +# define point(x, y) (Point){x, y} + +Point PointUtils_Arithmetic(Point *inst, Point *value); +bool PointUtils_Duplicate(Point *inst, Point *store); +bool PointUtils_Displacement(Point *inst, Point *value); +bool PointUtils_Equal(Point *inst, Point *other); + +typedef struct { + Point a; + Point b; +} Line; + +# define line(pa, pb) (Line){{pa.x, pa.y}, {pb.x, pb.y}} + +bool LineUtils_FromPoints(Line *inst, Point *pa, Point *pb); +bool LineUtils_FromPointAndLength(Line *inst, Point *p, int len); +Line LineUtils_Arithmetic(Line *inst, Line *value); +bool LineUtils_Duplicate(Line *inst, Line *store); +bool LineUtils_Displacement(Line *inst, Line *value); +int LineUtils_CalcLength(Line *inst); +bool LineUtils_Equal(Line *inst, Line *other); + +typedef struct { + Point a; + Point b; +} Rect; + +# define rect(pa, pb) (Rect){{pa.x, pa.y}, {pb.x, pb.y}} + +bool RectUtils_FromPoints(Rect *inst, Point *pa, Point *pb); +bool RectUtils_FromLines(Rect *inst, Line *la, Line *lb); +bool RectUtils_FromDiagonal(Rect *inst, Line *diag); +bool RectUtils_Equal(Rect *inst, Rect *other); + +#endif /* CYBERSIGHT_GEOMETRY_H */ diff --git a/README.md b/README.md index 119df40..bff9852 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # CyberSight -Use your Cyber Sight for exploring computational universe. \ No newline at end of file +Use your Cyber Sight for exploring computational universe.