Classes
Introduction
A pattern is a series of curves and lines that draws the outline of pieces that must be cut and sewn to create a garment. To these curve are added control points. In OpenPattern the lines and curves are saved in lists, control points in dictionaries.
OpenPattern is organized around classes which allow the creation of these points and curves and which inherit one from others. This structure has the advantage of adhering to the techniques pattern making. Indeed a shirt, a jacket or a vest are adaptations from a bodysuit, a dress derives from the assembly of a skirt and a bodysuit, finally skirts and trousers derive from generic forms called basics (basic skirt, basic pants).
OpenPattern currently has two levels of inheritance.
The parent class
Pattern: This is the general class that defines a pattern and the methods to drawing and manipulate it.Basic classes derived from Pattern:
Basic_Bodice,Basic_Trousers, Cuffs, Collars.The classes derived from the base classes: shirt, pyjamas etc… which inherit from
Basic_BodiceorBasic_Trousersetc…
Patterns call a class Point which allows to
define a pattern point with its position and properties.
This class redefines addition operations and offers various
manipulations such as rotation. The interest here is to have an object
flexible that allows you to start from a basic pattern and alter it.
Finally, a pattern is built from body measurements. These are stored
in a sqlite3 database contained in the measurement.db file.
This database contains a whole series of standard measurements from the various books mentioned above and can also contain the specific measurements that you will take on your loved ones.
Pattern Class
- class OpenPattern.Pattern.Pattern(pname='W38G', gender='w', pattern_name='P0', **kwargs)
Defines basic methods needed for pattern drafting
Notes: - Pattern methods originally used arrays or lists of values for points as arguments for calculations. - Since the development of the Point class I’ve progressively turned them to use it. I no longer use arrays for new methods. - Patterns can contain patterns (subpatterns) stored in a dictionnary of patterns
- Parameters:
m – dictionnary of size measurements
pname – name of size measurements
gender – gender
- add_comment(A=<OpenPattern.Points.Point object>, comment='HELLO', angle=0)
adds a comment to be plotted with legends
- Parameters:
A – Point where to place the comment
comment – the str comment
angle – the angle of rotation of the comment in radians
- add_curve(name='front_curve', coords=[0, 0], dic='front')
adds a curve to the corresponding dic
- Parameters:
name – str, curve name
coords – list of floats, x and y coordinates
dic – ‘front’ or ‘back’ dics to store the point
- add_dart(center=<OpenPattern.Points.Point object>, A=<OpenPattern.Points.Point object>, B=<OpenPattern.Points.Point object>, opening=0, draw_curves=False, order='lr', rotate_end='none')
adds a dart to a pattern if draw_curves = True: draws the curve when the dart is closed then rotates when opening the dart if rotate = none: rotation of the curves or segment decreases linearly to reach 0 at the end points. if rotate = left or right or both: also rotates the end points. The angle of rotation remains constant in this case NOT IMPLEMENTED YET
BEWARE : bug. At present draw_curves works if the pattern polygon is drawn in lr hence in a clockwise manner.
- Parameters:
center – Point position of the dart edge and center of rotation
B (A,) – Points segment to cut
opening – float width of the dart
- Return dart1, dart2:
points of the dart.
- Return type:
Points
- add_labelled_line(A, B, lab='HIP LINE', pos='t')
adds a labelled line to be plotted with legends typical exemples are HIP LINE, WAIST LINE
- Parameters:
B (A,) – Points between which to draw the line
lab – the str label
pos – char(1) t,b,l,r for position of the comment
- add_legends(ax)
adds legends and comments to the pattern
- Param:
ax: the ax on which to place the comments
- add_point(name='A', p=<OpenPattern.Points.Point object>, dic='front')
adds a point to the corresponding dic
- Parameters:
name – point name
p – point
dic – ‘front’ for front dic, ‘back’ for back dic
- add_scales(ax, val=5)
adds a blue scale at the bottom left
- Parameters:
ax – axis on which to plot
val – length (cm) of the scale
- copy()
Deepcopy pattern to a newly named one
- curve_offset(ilist, alpha, d, closed=False)
translates a curve by a vector of length d making an angle alpha with the local tangent
- Parameters:
plist – list of [x,y] points positions
:param alpha : real angle in radians :param d: offset distance in m
:return olist list of [x,y] offset points positions :rtype list of [x, y] coordinates
- distance(A, B)
Returns distance [AB]
- Parameters:
A – point given as Point or array([x,y])
B – point given as Point or array([x,y])
:return distance :rtype float
- draw(dic={'Pattern': 'My beautiful pattern'}, save=False, fname=None, info=True, legends=True, paper='FullSize', scale_val=5, overlay=False)
Draw pattern with legends and save it if asked for
- Parameters:
dic – dictionnary of informations to be printed
save – if true save to file
fname – filename
paper – paper size on which to save (for cuts)
scale_val – length of scale (in cm)
overlay – does the figure plot on an existing pattern
file format must always be pdf if you want the pattern to be cut in A4 or A3.
- Return fig:
:rtype matplotlib figure :return ax: :rtype matplotlib axis
- draw_pattern(dic_list=[], vertices_list=[], polyline_list=[], fig=None, ax=None, overlay=False)
- for each dic in dic_list
plots points given in dic
- for each vertices in vertices_list
draws the polygon defined by vertices_list
The figure is a 1:1 scaled pattern ready to print on a full size AO printer.
- Parameters:
dic_list – list of dictionnaries of points to be plotted as points with label
vertices_list – list of vertices list to be plotted as lines
:return fig, ax
- draw_subpatterns(overlay=False)
Draws each sub_pattern on a figure enables for different levels of patterning and composite Patterns
- generate_lists()
generates a list of point vertices and a list of point dictionnaries for drawing this method can only be called by children classes but is common to them
cheks if the front and back vertices are lists of points or if they are lists of lists of points in the former case adds the front and back vertices to a list of vertices_list in the latter adds the lists of vertices inside the front and back vertices list to the vertices list to be plotted. This trick enables to «cut» a pattern in as many pieces (polygons) as you want
The problem does not apply for the dictionnary as there is no need to cut them. They are only here to plot points
- get(pname='A', dic='front')
returns the point/curve pname from the corresponding dic
- Parameters:
pname – str point/curve name
dic – ‘front’ or back’ dictionnary from which to extrac the point
:return the chosen point or the list of coordinates of a curve :rtype Point or list
- get_measurements_json(pname='sophie')
Load stored measurements.
Measurements loaded are dictionnaries stored as json files in the measurements folder 23/12/2020: This is the original version now i use sqlite
- Parameters:
pname – name of json file as str
:return a dictionnary of size measurements :rtype: dic
- get_measurements_sql(pname='sophie')
Load stored measurements.
Measurements loaded are dictionnaries stored as json files in the measurements folder
- Parameters:
pname – name of pattern measurement code string
- Returns:
a dictionnary of size measurments
- Return type:
dic
- intersec_lines(A, B, C, D)
Finds the instersection between , lines AB and CD
- Parameters:
A – Point or array([x,y])
B – Point or array([x,y])
C – Point or array([x,y])
D – Point or array([x,y])
:return x,y coordinates :rtype Point or tuple
- intersec_manches(A, B, C, theta)
Intersection calculation
Finds the point of intersection G of the AB line with the line going through C and making an angle theta with the horizontal axis. Especially useful for sleeve heads. Does not work if AB is vertical !!!
- Parameters:
A – Point or array([x,y])
B – Point or array([x,y])
C – Point or array([x,y])
theta – angle in degrees
:return Point([x,y]) or (x,y) tuple of coordinates
- load_measurements(fname='measurement_sheet.csv')
Load measurements from a measurements sheet into the database
The measurement sheet has a specific format. a sample file
- is given in the measurements folder.
Once loaded the measurements become the pattern instance measurements
- Parameters:
fname – name of the measurement sheet to be loaded
- middle(A, B)
returns the middle point of [AB]
- Parameters:
A – Point or array([x,y])
B – Point or array([x,y])
:return x,y as an array
- mirror_point(A, M)
returns the mirror point of a point A with respect to point M <=> translate A by 2AM
- Parameters:
A – Point to mirror
M – center of symetry
:return mirrored point :rtype Point
- oriented_segment_angle(A, B)
Returns slope of segment [AB]
In this case the slope is positionned in the good quadrant depending on the relative positions of A and B
- Parameters:
A – Point or array([x,y])
B – Point or array([x,y])
- Returns:
angle in radians
- Return type:
float
- paper_cut(fig, ax, name='patternA4', paper='A4')
Cuts a pattern according to different paper sizes No overlap but the grid should suffice
- Parameters:
name – the output filename
paper – the paper format for the cut
- pistolet(points, kval=2, ax=None, kwargs={'color': 'blue', 'linestyle': 'solid'}, tot=False)
French curve calculation
calculates a spline of order kval from set of given points. if ax given draws the result on ax and returns length of Armhole if tot returns a list of 30 points to draw the spline curve.
- Parameters:
points – array of tuples or list of points
kval – int
ax – matplotlib axis
kwargs – dictionnary of drawing properties
tot – boolean deciding whether the entire curve is returned
- Returns:
Total distance if tot = False
- Returns:
Total distance and list of interpolated points if tot = True
- print_info(ax, model=None)
print generic info on each graph.
- Parameters:
ax – ax on which to print info
model – a dictionnary of informations to be printed
- Returns:
ax
- project_point(M, A, B)
returns the coordinates of the projection of M on the line (AB)
- Parameters:
M – points to be projected
A,B – points defining the line on which M is projected
- Returns:
projected point
- Return type:
- rotate(C=<OpenPattern.Points.Point object>, theta=0)
Rotation of the entire pattern of angle theta around center class.
In the case of points uses the rotate method for points if not does the rotation “manually”. BEWARE not to pass dic points directly as the center because this might induce spurious rotations.
- Parameters:
C – Point, center of rotation
theta – float angle of rotation in radians
- save_measurements_json(ofname=None)
Save new measurements
Save new measurements in ofname_data.json file in the mesures folder If no output format is given stores the data under the attribute self.pname 20/12/2020 changed to sql
- Parameters:
ofname (str) – output json filename
- save_measurements_sql(ofname=None)
Save new measurements
Save new measurements under ofname key in the measurement database If no output format is given stores the data under the attribute self.pname ! beware of the final path.
- Parameters:
ofname (str) – output wkey for measurements.db database
- segment(A, B, ax, kwargs={'color': 'blue'})
plots [AB] segment on ax
- Parameters:
A,B – points given as array([x,y])
ax – axis on which to plot
kwargs – dictionnary of drawing porperties
- segment_angle(A, B)
Returns slope of segment [AB]
- Parameters:
A – Point or array([x,y])
B – Point or array([x,y])
- Returns:
angle in radians
- Return type:
float
- segment_offset(A, B, alpha, d)
translates segment AB by a vector of length d making an angle alpha with AB
- Parameters:
A,B – Points
:param alpha : real angle in radians :param d: offset distance in m
- Returns:
Ap, Bp the offset points
- Return type:
- set_fold_line(A, B, pos)
- sets the fold_line list porperty to be added to legends.
if fold line already exists appends the new one for exemples (A,B,’right’) gives
A–> | | B–>
- Parameters:
B (A,) – fold line segment AB
pos – string parameter that defines how the arrows are to be set with regard to AB
- set_grainline(A=<OpenPattern.Points.Point object>, length=10, angle=1.570795)
sets the droit-fil list porperty to be added to legends.
- Parameters:
A – origin of the segment
length – length (cm) of the segment
angle – angle (in radians) of the segment
- translate(dx, dy)
translation of the entire pattern by dx, dy
- Parameters:
dy (dx,) – floats
- true_pistolet(point_list)
Fits a TRUE 100pt clothoid to three points designed primarily for sleeve holes but can do for any three point curve.
à adapter au différents types de courbures emmanchures, tour de col etc…
pour les jupes, col et tête de manche les spleen semblent très bien fonctionner
ce sont fondamentalement les emmanchures qui elles ne marchent pas bien.
On pourrait aussi probablement améliorer le tour d’encolure
il faut toujours commencer par la pente la plus douce et faire une Transformation de sorte à ce que la convexité soit bien orientée puis revenir au point initial
- Param:
point_list: list of three points
- Return xs, ys:
coordinates of clothoid curve points
- unfold(d, v, A, B)
Unfolds a pattern
Unfolds a pattern stored on the vertices list where AB represents the fold line.
- Parameters:
v – list of vertices
d – dictionnary of points
A,B – Points defining the fold line
- Returns:
vu, du dictionnary and list of original and mirrored points
- Return type:
list and dic
Skirts and Culottes
- class OpenPattern.Skirts.Basic_Skirt(pname='W6C', style='Chiappetta', gender='G', ease=8, curves=False, **kwargs)
Class to calculate and draw a basic Skirt pattern. Inherits from Pattern
Attributes
style: style used to draw the pattern as string (Gilewska, Donnanno, Chiappetta for now)
# Attributes that control the dictionnaries used for size measurements age: ade of the kid in Chiapetta’s patterns pname: measurements used corresponding to a json file
# Variables obtained from the basic calculations for Skirts # dics used here:
Front_dic
Back_dic
# lists of vertices:
Back_vertices Front_vertices
- Gilewska_basic_skirt()
Basic pencil skirt whith slight asymmetry
- chiappetta_basic_skirt()
Basic pencil skirt (jupe droite) for girls between 2 and 16.
- donnanno_basic_skirt()
Pencil skirt
- class OpenPattern.Skirts.Culotte(pname='sophie', style='Donnanno', gender='W', ease=8, overlay=False, model='basic', **kwargs)
Transformations of the Basic pencil skirt into culottes
Donnanno
- class OpenPattern.Skirts.Skirt_transform(pname='W6C', style='Chiappetta', gender='G', ease=8, curves=False, overlay=False, model='shifted', side_offset=5, **kwargs)
Transformations of the Basic pencil skirt
- Donnanno
shifted side seams with kick pleats
- A_Line(side_offset=5)
A-line adapted from the basic pencil skirt
R = [E1F]
theta = side_offset/R the most simple way to draw a correct side
add F1 a control point at side_offset from the original position of F
rotate F by theta around E1
rotate E2 by theta around E1
redraw the side curves
draw the curve F-F1-C for the Hem.
do the opposite for the front
offset all points before drawing
- Parameters:
side_offset – the value of the lateral enlargement of the side.
- Flared_A_Line(side_offset=5)
Flared A line. add the closure of darts and corresponding expansion at the hem.
to rotate a portion of the pattern calculate angle of rotation = angle of dart to be closed select points to be rotated select curves to be rotated rotate around the dart point
- shifted_side_seams(offset=2, pleat_height=20, pleat_width=8)
Moves the side by offset cm so the seam is positionned slightly at the back of the Skirt
- Parameters:
offset – float or int value of side offset
- class OpenPattern.Skirts.Waistband(pname='W6C', ease=8, height=5, style='Donnanno', **kwargs)
draws a waist band with different styles depending on init arguments
Trousers
- class OpenPattern.Trousers.Basic_Trousers(pname='M44D', gender='m', style='Donnanno', darts=False, wfd=None, **kwargs)
Class used to calculate the pattern of basic trousers Inherits from Pattern
- Attributes:
# dics used here for pattern construction points and labels: Back_dic Front_dic
# lists of vertices to draw pattern curves: Back_vertices Front_vertices
# list of points to be used for alterations Trousers_Front_Contour_list Trousers_Back_Contour_list
# curves obtained from spline interpolation: # SORRY IT’S IN FRENCH fourche_arriere interieur_arriere exterieur_arriere fourche_avant interieur_avant exterieur_avant ceinture_avant
- Donnanno_add_darts()
Add front and back darts. TODO darts properties should calculated from waist-hip difference. at present they are set by default to the typical values given by Donnanno Normally the maximum absorption with 3x2 darts is going to be 4 x 2 (front) + 2 x 3 (back) = 14cm. then you have to save on the sides or the central darts As usual Chiappetta offers a solution at least for men if no dart then you take from the sides and middle darts in a uniform manner hence (hip-waist)/4 and you redraw if pleats (not darts for men) she leaves the back untouched and adds 2x2 pleats of the necessary length hence ((hip - waist) - 2 x back)/4 for each pleat
- Donnanno_back_trousers(delta=6)
Calculate back Trousers’ pattern
- Args:
delta: distance between patterns as int (or float)
- Donnanno_front_trousers()
Calculate front Trousers’ pattern Essentially the same for women and men with some slight differences
- draw_basic_trousers(dic={'Pattern': 'Basic Trousers'}, save=False, fname=None, paper='FullSize')
Draw basic trousers’ pattern
- Args:
dic: information to be written on the pattern as dictionnary save: if True save pattern to file fname: pattern file name as str paper: paper type as str
- Returns:
ax: instance of axis used for drawing
- class OpenPattern.Trousers.Bermudas(pname='gregoire', gender='m', height_above_knee=4, wfd=None, **kwargs)
Bermudas based on Donnanno darted basic trousers
specific Args: height_above_knee: added length of Trousers
- class OpenPattern.Trousers.Flared_pants(pname='gregoire', gender='m', save=False, paper='FullSize', flare_length=2, flare_width=5, flare_start=0, **kwargs)
Flared pants based on Donnanno dartless basic trousers
- supplementary Args:
flare_length: added length of Trousers flare_width: added width at the hem, flare_start: place to start relative to Knee
- class OpenPattern.Trousers.Pants_block(pname='gregoire', gender='m', save=False, paper='FullSize', overlay=False, classic=True, **kwargs)
Adapted from Pants_block for things like jogging or pyjamas. Donnanno. I used it to make baggy pyjamas to my teenage son…
the front and back measurements at the bottom are calculated on the basis of the ankle measurement.
It is impossible to comply with donnanno’s instructions because of an incoherence AV = hip +6 as the back frame is 1/2 hip +2 and the front frame 1/ Hip front + back = hip + 2 then the distance between the two pants pieces must be 4 not 6 in order to comply with AV
so either we comply with AV or we comply with VZ being at 3cm from the two frames and in this case V is offset by 2cm towards the front which keeps the sligh difference between front and back parts. I keep VZ as 3cm apart from the front and back patterns so V is 1cm to the left of the middle of AV
Bodices class
- class OpenPattern.Bodices.Basic_Bodice(pname='M44G', gender='m', style='Gilewska', age=99, ease=8, hip=False, Back_Front_space=4, **kwargs)
Class to calculate and draw a basic Bodice pattern. For men it’s traditionnally more a shirt than a Bodice. Inherits from Pattern
Attributes
style: style used to draw the pattern as string (Gilewska, Donnanno, Chiappetta for now)
# Attributes that control the dictionnaries used for size measurements age: ade of the kid in Chiappetta’s patterns gender: gender pname: measurements used corresponding to a json file
# Variables obtained from the basic calculations for Bodices # dics used here:
Bodice_points_dic curves_dic
# lists of vertices:
Bodice_Back_vertices Bodice_Front_vertices
- Donnanno_basic_fitted_sleeve(straight=True)
Fitted seeve for Donnano bodice without dart
- param: straight: if true draws a straight sleeve
if false draws a waist fitted sleeve (NOT DONE YET)
- Donnanno_bodice_without_dart_m(bust_ease=24)
- Calculation of bodice with no dart
for Men using Donnanno technique This Bodice comes with ease applied
NOT READY THERE ARE PROBLEMS FOR BUST CALCULATIONS AND DONNANNO MAKES ARMHOLES THAT ARE VERY FLAT
- Parameters:
bust_ease – ease to be applied.
- Donnanno_bodice_without_dart_w(bust_ease=8)
- Calculation of bodice with no dart
for Women using Donnanno technique This Bodice comes with ease applied
TODO: I haven’t had time to normalize the point labelling so it can not be mixed with Chiappetta or Gilewsa
- Parameters:
bust_ease – ease to be applied.
- Gilewska_basic_bodice_m(BF_space=10)
- Calculation of bodice with no dart
for Men using Gilewska technique
- Parameters:
BF_space – distance between front and back patterns on the draft
- Gilewska_basic_bodice_w(sep=10)
Basic Bodice for woment using Gilewska technique
Trying to get standard first letter Caps [then minor] W: waist Sl: sleeve B: bust H: height C: collar Sh: shoulder DSl: depth of sleeve
Last Letter B: Back F: Front
no numbering when on the fold line numbering when on the sleeve side
CP: Control Point
- Parameters:
sep – distance between front and back patterns on draft
- Gilewska_basic_sleeve_m()
Calculation of basic sleeve for Men using Gilewska technique
- Gilewska_basic_sleeve_w()
Basic sleeve for Women using Gilewska technique
- add_bust_dart()
Add darts to dartless Bodice
- add_waist_dart()
Add waist darts to basic Bodice
- chiappetta_armhole_sleeve_m(plot=False, ease=3, folds=1, fold_width=1, fente=11, wrist=5)
Sleeve drawn from armhole curves using the method for men works for women too
This sleeve pattern is often used for shirts
Its drafting is a bit complex because we need some rotations and translations but normally it works
- Parameters:
plot – whether to plot the sleeve. Do not remember why I added this option
ease – ease at waist for cuff and folds
folds – number of folds on the waist
fold_width – with of each fold
fente – waist cut length (frenglish)
wrist – wrist height (basically wrist ~ cuff height)
- chiappetta_basic_bodice(age=14, d_FB=5)
- Calculation of bodice with no dart
for children using Chiappetta technique differences arise with age and sex on the shoulder angle and the use of carrure devant for the girls.
- Parameters:
age – age of the child, the pattern drafting depends on the age
d_FB – distance between front and back patterns on the draft
- chiappetta_basic_bodice__ori_m(BF_space=2)
Calculation of the basic bodice for men
Chiappetta has it (as always)! front to the left, back to the right as always in Chiappetta
- Parameters:
BF_space – distance between front and back 1/2 bodices
- chiappetta_basic_bodice_m()
Calculation of the basic bodice for men
Chiappetta has it (as always)! front left, back right as always in Chiappetta
- chiappetta_basic_sleeve_m()
Basic Sleeve for men
Straight sleeve base without cuff
- draw_bodice(dic={'Pattern': 'Dartless bodice'}, save=False, fname=None, paper='FullSize')
Draws Basic Bodice with legends and save it if asked for
- Parameters:
dic – dictionnary of informations to be printed
save – if true save to file
fname – filename
paper – paper size on which to save (for cuts)
:return fig :rtype matplotlib.figure :return ax :rtype matplotlib.axis
- draw_sleeves(save=False, fname=None, paper='FullSize')
draws the basic sleeve
- Parameters:
save – if true save to file
fname – filename
paper – paper size on which to save (for cuts)
:return fig :rtype matplotlib figure :return ax :rtype matplotlib axis
Shirts
- class OpenPattern.Shirts.Shirt(pname='M40mC', gender='m', style='Chiappetta', age=99, ease=0, lower_length=25, hip=False, Back_Front_space=12, collar_ease=1, sleeve_lowering=3, side_ease=4, shoulder_ease=1, button_overlap=2, **kwargs)
Shirt class inherits from bodice can be used to draw shirt dresses by ajusting the value of lower_lenght
for now only Basinc_shirt method the method has to be called
- basic_shirt_bodice(style='Chiappetta')
transformation of the bodice into a shirt
- Parameters:
style – stylist
- yoked_shirt_bodice()
yoked shirt but not finished…
Ancillary classes: Plackets, Cuffs and Collars
- class OpenPattern.Collars.Collars(pname='sophie', gender='w', style='Gilewska', collar_style='Officer', overlap=0, collar_height=3, up_collar_height=6.5, **kwargs)
Class to calculate collar pattern
Collars must be called or instanciated after shirt or bodice instances because then the back and front collar lengths are stored on a json measurement file or sql database.
styles available : Officer, OnePiece, TwoPieces
Again and again issues with naming conventions to be solved
- calculate_collar_gilewska_m(overlap=0, collar_height=3, up_collar_height=6.5)
C: collar angle points l,r,m: left, right, middle u,d: up, down
- class OpenPattern.Cuffs.Cuffs(pname='sophie', gender='w', style='Gilewska', age=12, cuff_style='Simple', overlap=2, width=7, ease=3, **kwargs)
Class to calculate cuff pattern
styles available: Simple, French
- calculate_cuffs_gilewska_m(overlap=2, width=5, ease=3)
C: Cuff O: Overlap B: Buttonhole l, r : left, right u, d, m : up, down, middle
- class OpenPattern.Placket.Placket(pname='sophie', gender='w', placket_style='SimpleOneSide', slit_length=11, **kwargs)
Sleeve placket and underlap (if wanted)
Waistcoats
- class OpenPattern.Waist_Coats.Waist_Coat(pname='M44G', gender='m', style='Gilewska', age=12, ease=8, wc_style='Classical', overlap=False, **kwargs)
first test for alteration capacities of my pattern system. its hard !
- add_legends(ax)
Adds common legends to the Bodice pattern
- Args:
ax on which to plot
- Returns:
ax
This method is overloaded As some legends to change. There is probably a means to escape overloading
- cal_wc()
define the style
calculate the Bodice define the movement of points le faire à la main et ensuite passer au calcul
Points Classes
- class OpenPattern.Points.Point(pos=[0, 0], pid=None, point_type='Pattern', comment=None, pname_ori=None)
Generic point class
2D implementation for now
- Attributes:
x,y : floats and pos [x,y] for position point_type : str generic type of point for seaches comment : str comments on the point pname_ori : str original point name in cas of pattern points. Not really used for now. pid: point id
- add(*args)
Addition
- Args: two possible types
a point, an array , a list => add(p) two points => add(x,y)
- angle_to(B)
Returns slope of segment to B
- Args:
B: Point
- Returns:
angle in radians
- copy()
Deepcopy point to a newly named one
- distance_to(B)
returns distance to B
- Args:
B: point
- Returns:
distance as a float
- get_track(for_plot=True)
Returns the track
- Args:
for_plot: if True returns the transposed track (for plot)
- mat(*args)
Matrix product
- Args:
A 2x2 matrix or list of ints of floats
- mat_out(*args)
Matrix product of self with A -> new point
- Args:
A 2x2 matrix or list of ints of floats
- middle(B)
returns the middle point of [self B]
- Args:
B: point
- Returns:
Point([x,y])
- move(mlist=[0, 0], mtype='dxdy', unit='deg')
Move point by a certain amount
- Can either be done in cartesian coordinates
mtype = ‘dxdy’ and mlist = [dx, dy]
- or polar coordinates
mtype = ‘pol’ and mlist = [theta, d], theta !
- Args:
mtype: str type of translations mlist: 2x1 list of float or int deg: tells the unit of theta deg: degrees, rad: radians
- moveto(*args)
move point to a certain location
- Args: can be
Point => move to the location of the Point given Position 2x1 list or array position x,y
- plot(ax, name=None, kwargs={'color': 'blue', 'marker': 'o'})
plot point
- reset()
Go back to original
- rotate(rot_center=[0, 0], theta=0, unit='deg')
rotate a point from theta around rot_center
- Args:
rot_center: can a Point, a 2x1 matrix or list theta: angle of rotation unit: unit of angle of rotation deg for degrees and rad for radians
- scal(*args)
Scalar product Different from * because it can also be a scalar product of vectors
- Args:
An int a => a*x, a*y A Point or a 2x1 array or list => Dot product in that case returns x1x2 + y1y2
- segment_to(B, ax, kwargs={'color': 'blue'})
plots [self B] segment on ax
- Args:
B: Point([x,y]) ax: axis on which to plot kwargs: dictionnary of drawing porperties
- sub(*args)
Substraction
- Args: two possible types
a point, an array , a list => add(p) two points => add(x,y)
- vec(*args)
Vector product
- Args:
A point, an array or a list of two values
- Returns:
The vector product as a number