Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b2b873acc8 | ||
|
8bc5c25008 |
4
Figure.h
4
Figure.h
@ -24,18 +24,22 @@ static inline const char* Figure_type (const Figure *this)
|
|||||||
{
|
{
|
||||||
return this->vtable->type ();
|
return this->vtable->type ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Figure* Figure_clone (const Figure *this)
|
static inline Figure* Figure_clone (const Figure *this)
|
||||||
{
|
{
|
||||||
return this->vtable->clone (this);
|
return this->vtable->clone (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Figure_destroy (Figure *this)
|
static inline void Figure_destroy (Figure *this)
|
||||||
{
|
{
|
||||||
this->vtable->destroy (this);
|
this->vtable->destroy (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Figure_draw (const Figure *this)
|
static inline void Figure_draw (const Figure *this)
|
||||||
{
|
{
|
||||||
this->vtable->draw (this);
|
this->vtable->draw (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double Figure_area (const Figure *this)
|
static inline double Figure_area (const Figure *this)
|
||||||
{
|
{
|
||||||
return this->vtable->area (this);
|
return this->vtable->area (this);
|
||||||
|
15
Object.h
15
Object.h
@ -14,4 +14,19 @@ typedef struct Object
|
|||||||
|
|
||||||
} Object;
|
} Object;
|
||||||
|
|
||||||
|
static inline const char* Object_type (const Object *this)
|
||||||
|
{
|
||||||
|
return this->vtable->type ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Object* Object_clone (const Object *this)
|
||||||
|
{
|
||||||
|
return this->vtable->clone (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void Object_destroy (Object *this)
|
||||||
|
{
|
||||||
|
this->vtable->destroy (this);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // __OBJECT_H__
|
#endif // __OBJECT_H__
|
||||||
|
@ -69,7 +69,7 @@ double __Polygon_area (const Polygon *this)
|
|||||||
this->points[(i + 1) % this->npoints].x * this->points[i].y;
|
this->points[(i + 1) % this->npoints].x * this->points[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s * 0.5;
|
return fabs (s) * 0.5;
|
||||||
// Trapezium rule for convex and non-convex polygons
|
// Trapezium rule for convex and non-convex polygons
|
||||||
// S=abs(сумма{(x[i+1]-x[i])*(y[i+1]+y[i])/2})
|
// S=abs(сумма{(x[i+1]-x[i])*(y[i+1]+y[i])/2})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user