Geometry¶
Libembroidery 1.0.0-alpha https://www.libembroidery.org
A library for reading, writing, altering and otherwise processing machine embroidery files and designs.
Also, the core library supporting the Embroidermodder Project’s family of machine embroidery interfaces.
Copyright 2018-2025 The Embroidermodder Team Licensed under the terms of the zlib license.
Only uses source from this directory or standard C libraries, not including POSIX headers like unistd since this library needs to support non-POSIX systems like Windows.
The Geometry System
Functions
-
EmbVector emb_vector(EmbReal x, EmbReal y)¶
Create an EmbVector from data.
-
EmbVector emb_vector_normalize(EmbVector vector)¶
Finds the unit length vector a result in the same direction as a vector.
-
EmbVector emb_vector_scale(EmbVector vector, EmbReal magnitude)¶
The scalar multiple a magnitude of a vector. Returned as a vector.
-
EmbVector emb_vector_add(EmbVector a, EmbVector b)¶
The sum of two vectors returned as a vector.
-
EmbVector emb_vector_average(EmbVector a, EmbVector b)¶
The average of two vectors returned as a vector.
-
EmbVector emb_vector_subtract(EmbVector v1, EmbVector v2)¶
The difference between two vectors returned as a result.
-
EmbReal emb_vector_dot(EmbVector a, EmbVector b)¶
The dot product of two vectors returned as a EmbReal.
-
EmbReal emb_vector_cross(EmbVector a, EmbVector b)¶
The “cross product” as vectors a and b returned as a real value.
Technically, this is the magnitude of the cross product when the embroidery is placed in the z=0 plane (since the cross product is defined for 3-dimensional vectors).
-
EmbVector emb_vector_transpose_product(EmbVector v1, EmbVector v2)¶
Since we aren’t using full 3D vector algebra here, all vectors are “vertical”. so this is like the product v1^{T} I_{2} v2 for our vectors a v1 and v2 so a “component-wise product”. The result is stored at the pointer a result.
-
EmbReal emb_vector_length(EmbVector vector)¶
The length or absolute value of the vector a vector.
-
EmbReal emb_vector_relativeX(EmbVector a1, EmbVector a2, EmbVector a3)¶
-
EmbReal emb_vector_relativeY(EmbVector a1, EmbVector a2, EmbVector a3)¶
-
EmbReal emb_vector_angle(EmbVector v)¶
-
EmbVector emb_vector_unit(EmbReal alpha)¶
The unit vector in the direction a angle.
-
EmbReal emb_vector_distance(EmbVector a, EmbVector b)¶
-
void emb_geometry_move(EmbGeometry *obj, EmbVector delta)¶
-
int emb_approx(EmbVector point1, EmbVector point2)¶
-
EmbReal emb_apothem(EmbGeometry *g, int *error)¶
-
EmbReal emb_sagitta(EmbGeometry *g, int *error)¶
-
EmbVector emb_start(EmbGeometry *g, int *error)¶
-
EmbVector emb_end(EmbGeometry *g, int *error)¶
-
EmbReal emb_width(EmbGeometry *g, int *error)¶
-
EmbReal emb_height(EmbGeometry *g, int *error)¶
-
EmbReal emb_radius(EmbGeometry *g, int *error)¶
-
EmbReal emb_radius_major(EmbGeometry *g, int *error)¶
-
EmbReal emb_radius_minor(EmbGeometry *g, int *error)¶
-
EmbReal emb_diameter_major(EmbGeometry *g, int *error)¶
-
EmbReal emb_diameter_minor(EmbGeometry *g, int *error)¶
-
EmbReal emb_diameter(EmbGeometry *g, int *error)¶
-
EmbVector emb_quadrant(EmbGeometry *geometry, int degrees, int *error)¶
-
EmbReal emb_angle(EmbGeometry *geometry, int *error)¶
-
EmbReal emb_start_angle(EmbGeometry *geometry, int *error)¶
-
EmbReal emb_end_angle(EmbGeometry *geometry, int *error)¶
-
EmbReal emb_arc_length(EmbGeometry *g, int *error)¶
-
EmbReal emb_area(EmbGeometry *g, int *error)¶
-
EmbVector emb_center(EmbGeometry *g, int *error)¶
-
EmbVector emb_chord(EmbGeometry *g, int *error)¶
-
EmbReal emb_included_angle(EmbGeometry *g, int *error)¶
-
char emb_clockwise(EmbGeometry *geometry, int *error)¶
-
int emb_set_start_angle(EmbGeometry *geometry, EmbReal angle)¶
-
int emb_set_end_angle(EmbGeometry *geometry, EmbReal angle)¶
-
int emb_set_start_point(EmbGeometry *geometry, EmbVector point)¶
-
int emb_set_mid_point(EmbGeometry *geometry, EmbVector point)¶
-
int emb_set_end_point(EmbGeometry *geometry, EmbVector point)¶
-
int emb_set_radius(EmbGeometry *g, EmbReal radius)¶
-
int emb_set_diameter(EmbGeometry *geometry, EmbReal diameter)¶
-
int emb_set_area(EmbGeometry *geometry, EmbReal area)¶
-
int emb_set_circumference(EmbGeometry *geometry, EmbReal circumference)¶
-
int emb_set_radius_major(EmbGeometry *geometry, EmbReal radius)¶
-
int emb_set_radius_minor(EmbGeometry *geometry, EmbReal radius)¶
-
int emb_set_diameter_major(EmbGeometry *geometry, EmbReal diameter)¶
-
int emb_set_diameter_minor(EmbGeometry *geometry, EmbReal diameter)¶
-
EmbReal emb_circumference(EmbGeometry *geometry, int *error)¶
-
EmbGeometry *emb_init(int type_in)¶
-
void emb_free(EmbGeometry *obj)¶
-
EmbRect emb_boundingRect(EmbGeometry *obj)¶
-
EmbGeometry emb_arc(EmbReal x1, EmbReal y1, EmbReal x2, EmbReal y2, EmbReal x3, EmbReal y3)¶
-
char emb_arc_clockwise(EmbGeometry g)¶
-
int emb_set_center(EmbGeometry *g, EmbVector point)¶
-
void emb_set_color(EmbGeometry *obj, EmbColor color)¶
-
void emb_set_color_rgb(EmbGeometry *obj, unsigned int rgb)¶
-
void emb_set_linetype(EmbGeometry *obj, int lineType)¶
-
void emb_set_line_weight(EmbGeometry *obj, float lineWeight)¶
-
EmbVector emb_base_rubber_point(EmbGeometry *obj, const char *key)¶
-
const char *emb_base_rubber_text(EmbGeometry *obj, const char *key)¶
-
void emb_circle_main(void)¶
-
void emb_circle_set_area(EmbCircle *circle, float area)¶
-
void emb_ellipse_main(void)¶
-
EmbVector embRect_bottomLeft(EmbRect rect)¶
-
EmbVector embRect_bottomRight(EmbRect rect)¶
-
EmbGeometry emb_circle(EmbReal x, EmbReal y, EmbReal radius)¶
-
int getCircleCircleIntersections(EmbCircle c0, EmbCircle c1, EmbVector *p0, EmbVector *p1)¶
-
int getCircleTangentPoints(EmbCircle c, EmbVector point, EmbVector *t0, EmbVector *t1)¶
-
EmbEllipse emb_ellipse_init(void)¶
-
EmbReal emb_ellipse_diameterX(EmbEllipse ellipse)¶
-
EmbReal emb_ellipse_diameterY(EmbEllipse ellipse)¶
-
void emb_ellipse_setSize(float width, float height)¶
-
int emb_round(EmbReal x)¶
-
EmbReal radians(EmbReal degree)¶
-
EmbReal degrees(EmbReal radian)¶
-
EmbVector emb_line_normalVector(EmbLine line, int clockwise)¶
-
EmbVector emb_line_toVector(EmbLine line)¶
-
EmbVector emb_line_intersectionPoint(EmbLine line1, EmbLine line2, int *emb_error)¶
-
EmbRect emb_rect(EmbReal x, EmbReal y, EmbReal w, EmbReal h)¶
-
void textSingle_setJustify(EmbGeometry *g, const char *justify)¶
-
int emb_backwards(EmbGeometry *g, int *error)¶
-
int emb_bold(EmbGeometry *g, int *error)¶
-
int emb_bulge(EmbGeometry *g, int *error)¶
-
EmbReal emb_chord_length(EmbGeometry *g, int *error)¶