(ADD) Point, Line, Rect

This commit is contained in:
William
2024-05-24 23:49:17 +08:00
parent 2e40ef2a1b
commit 58bbfc54e8
3 changed files with 50 additions and 1 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
vscGetReady.sh
*~
main
test.sh

View File

@@ -0,0 +1,45 @@
#ifndef CYBERSIGHT_GEOMETRY_H
# define CYBERSIGHT_GEOMETRY_H
# include <Compound/common.h>
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 */

View File

@@ -1,3 +1,3 @@
# CyberSight # CyberSight
Use your Cyber Sight for exploring computational universe. Use your Cyber Sight for exploring computational universe.