diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo
index 591ca50..d7ef047 100644
--- a/docs/build/html/.buildinfo
+++ b/docs/build/html/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
-config: caf5792fd17da2c604992977d35f1f60
+config: 2580fd671a06d4c76900a6be80ac7ca7
tags: 645f666f9bcd5a90fca523b33c5a78b7
diff --git a/docs/build/html/_modules/index.html b/docs/build/html/_modules/index.html
index bca247e..d872c66 100644
--- a/docs/build/html/_modules/index.html
+++ b/docs/build/html/_modules/index.html
@@ -34,6 +34,8 @@
#!/usr/bin/env python# -*- coding: utf-8 -*-
-"""Read and write data to or from file and manipulate data structures.
+"""Read and write data to or from file and manipulate data
+structures.
-:Date: 2019-10-11
+:Date: 2019-12-28.. module:: data :platform: *nix, Windows
@@ -48,6 +49,7 @@
importmathimportpickleimportcollections
+importre
[docs]defread_columns(file_name,x_column,y_column,default=None,verbose=False):
+ """Read ascii data file.
+
+ :param file_name: file to read
+ :type file_name: str :param x_column: column index for the x data (first column is 0) :type x_column: int :param y_column: column index for the y data (first column is 0)
@@ -95,8 +111,6 @@
:returns: x and y :rtype: tuple(list, list) """
- importre
-
x=defaulty=default
@@ -167,6 +181,14 @@
# every dump needs a loadpickle.dump(object_data,output,pickle.HIGHEST_PROTOCOL)
+
[docs]defprint_list(lst):
+ """Print list, one list element per line.
+
+ :param lst: list to print
+ :type lst: list
+ """
+ [print(row)forrowinlst]
+
[docs]deffold_list(lst,n):"""Convert one-dimensional kx1 array (list) to two-dimensional mxn array. m = k / n
@@ -238,6 +260,24 @@
lst=[round(start+step*i,exponent)foriinrange(n)]returnlst
+
[docs]defunique_list_hashable(sequence):
+ """
+ faster using set() but elements of the sequence must be hashable.
+ unhashable types: 'list'
+ """
+ # https://stackoverflow.com/a/37163210
+ used=set()
+ # .add(x) will always be falsy
+ return[xforxinsequenceifxnotinusedand(used.add(x)orTrue)]
+
+
[docs]defunique_list(sequence):
+ """
+ """
+ # https://stackoverflow.com/a/37163210
+ used=[]
+ # .append(x) will always be falsy
+ return[xforxinsequenceifxnotinusedand(used.append(x)orTrue)]
+
[docs]defunique_ending(ids,n=1):"""From id list get list with unique ending.
@@ -249,12 +289,11 @@
:returns: unique ending of ids :rtype: list """
- ifidsisnotNone:
- x=[idi[-n:]foridiinids]
- iflen(x)>len(set(x)):
- returnunique_ending(ids,n+1)
- else:
- returnx
[docs]defget_id(ids,uide):"""Get full id from unique id ending.
@@ -269,6 +308,87 @@
"""# take first element, because we know it is a unique endingreturn[idiforidiinidsifidi.endswith(uide)][0]
+
+
[docs]deffind_last(sequence,pattern):
+ """Find last last occurance in sequence (text)
+
+ :param sequence: text to search in
+ :type sequence: str
+ :param pattern: search pattern
+ :type pattern: str
+
+ :returns: index (-1 if pattern not in sequence)
+ :rtype: int
+ """
+ ifpatterninsequence:
+ returnlen(sequence)-1-sequence[::-1].find(pattern)
+ return-1
+
+
[docs]defstr_between(text,left,right):
+ """Get text between two pattern.
+
+ Text can be multi-line.
+
+ :param text: text to search in
+ :type text: str
+ :param left: left pattern
+ :type left: str
+ :param right: right pattern
+ :type right: str
+
+ :returns: text between the left and right pattern
+ :rtype: str
+ """
+ try:
+ returnre.search(left+'(.+?)'+right,text,re.DOTALL).group(1)
+ except:
+ return''
+
+
[docs]defstr_to_list(string,delimiter=';\n',newline_replacement=''):
+ r"""Converts a string with block information into a list.
+
+ This function un-wraps multi-line block information into one line.
+
+ :param string: string with block information
+ :type string: str
+ :param delimiter: block delimiter (default = ';\n'). This will be
+ removed from the resulting list.
+ :type delimiter: str
+ :param newline_replacement: block lines replacement (default = '')
+ :type newline_replacement: str
+
+ :returns: list of block information
+ :rtype: list
+
+ .. note:: Every line is left striped. Empty line are ignored.
+
+ :Example:
+
+ ::
+
+ before (string):
+ FILE_DESCRIPTION(('Open CASCADE Model'),'2;1');
+ FILE_NAME('Open CASCADE Shape Model','2019-10-14T14:32:20',('Author'),(
+ 'Open CASCADE'),'Open CASCADE STEP processor 7.1','Open CASCADE 7.1'
+ ,'Unknown');
+ FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
+
+ after (list elements one per line):
+ FILE_DESCRIPTION(('Open CASCADE Model'),'2;1')
+ FILE_NAME('Open CASCADE Shape Model','2019-10-14T14:32:20',('Author'),('Open CASCADE'),'Open CASCADE STEP processor 7.1','Open CASCADE 7.1','Unknown')
+ FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'))
+ """
+ # for example blocks are seperated by ;\n
+ blocks=string.split(delimiter)
+ lines=[]
+ forblockinblocks:
+ # un-wrap block to single line
+ # remove \n and replace with newline_replacement
+ line=newline_replacement.join([row.lstrip()for
+ rowinblock.split('\n')])
+ # append line if True (if it has some content)
+ lines.append(line)ifbool(line)elseFalse
+ returnlines
[docs]classstep:
+ r"""STEP reader class.
+
+ 1st read a STEP file.
+ 2nd convert header and data section string to list of commands.
+
+ The STEP file string can have commands distributed over several
+ lines, the commands are seperated by ``;\n``. This class un-wraps
+ each command into one line (remove ``\n``) and removes empty lines.
+
+ :Example:
+
+ ::
+
+ header part of a step file (between HEADER; and ENDSEC;):
+ FILE_DESCRIPTION(('Open CASCADE Model'),'2;1');
+ FILE_NAME('Open CASCADE Shape Model','2019-10-14T14:32:20',('Author'),(
+ 'Open CASCADE'),'Open CASCADE STEP processor 7.1','Open CASCADE 7.1'
+ ,'Unknown');
+ FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
+
+ will result in (but as a list):
+ FILE_DESCRIPTION(('Open CASCADE Model'),'2;1')
+ FILE_NAME('Open CASCADE Shape Model','2019-10-14T14:32:20',('Author'),('Open CASCADE'),'Open CASCADE STEP processor 7.1','Open CASCADE 7.1','Unknown')
+ FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'))
+ """
+ def__init__(self,file_name):
+ self.file_str=read(file_name)
+
+ step_str=str_between(self.file_str,'ISO-10303-21;',
+ 'END-ISO-10303-21;')
+ ifnotstep_str:
+ raiseValueError('File is not a step file')
+
+ header_str=str_between(step_str,'HEADER;','ENDSEC;')
+ self.header=str_to_list(string=header_str,delimiter=';\n',
+ newline_replacement='')
+ data_str=str_between(step_str,'DATA;','ENDSEC;')
+ self.data=str_to_list(string=data_str,delimiter=';\n',
+ newline_replacement='')
+
+
[docs]defstr_to_cmd_args(cmd_str):
+ """
+ Using negative lookahead to match all the commas which are not
+ inside a parenthesis and then split the string at the commas.
+
+ :Example:
+
+ ::
+
+ CARTESIAN_POINT('',(0.E+000,0.E+000,0.E+000))
+ will become
+ command = 'CARTESIAN_POINT'
+ arguments = ['', '(0.E+000,0.E+000,0.E+000)']
+ """
+ importre
+
+ command=cmd_str[0:cmd_str.find('(')]
+ inside_parenthesis=cmd_str[(cmd_str.find('(')+1):find_last(cmd_str,')')]
+ arguments=re.split(r',\s*(?![^()]*\))',inside_parenthesis)
+ # arguments = [i.strip() for i in inside_parenthesis.split(',')] # does not work for arguments with commas inside the parenthsis
+ returncommand,arguments
[docs]defline_geometry(p1,p2):
+ # (normally)
+ # edge_curve.edge_geometry.curve_3d.pnt.coordinates is
+ # equal to p1 (see above) this is
+ # edge_curve.edge_start.vertex_geometry.coordinates
+ # p2 could be calculated from
+ # edge_curve.edge_geometry.curve_3d.dir.orientation.direction_ratios
+ # and edge_curve.edge_geometry.curve_3d.dir.magnitude
+ # vector = [i*edge_curve.edge_geometry.curve_3d.dir.magnitude for
+ # i in edge_curve.edge_geometry.curve_3d.dir.orientation.direction_ratios]
+ returnLine(point1=p1,point2=p2)
+
+importmath
+
[docs]defarc_circle_geometry(conic,p1,p2,ellipse=False):
+
+ z=Direction(*conic.position.axis.direction_ratios)
+ x=Direction(*conic.position.ref_direction.direction_ratios)
+ y=Direction.cross(z,x)
+ cs_gl=CS(x,y,z)# transform from global to local
+ cs_lg=CS.transposed(cs_gl)# transform from local to global
+
+ location=vector(conic.position.location.coordinates)
+
+ ifp1==p2:# Full Circle or Ellipse
+ ifellipse:
+ a=conic.semi_axis_1
+ b=conic.semi_axis_2
+ returnEllipse(a,b).ch_cs(cs_lg).translate(*location)
+ # else Circle
+ radius=conic.radius
+ returnCircle(radius).ch_cs(cs_lg).translate(*location)
+ # else Arc
+ # points relative to the location
+ v1,v2=p1-location,p2-location
+ #ang1, ang2 = vector.ang(x, v1), vector.ang(x, v2)
+ # relative points transformed into circle coordinate system
+ # relative point lay in local xy-plane
+ vl1,vl2=vector(v1).ch_cs(cs_gl),vector(v2).ch_cs(cs_gl)
+ ang1,ang2=math.atan2(*vl1[:2][::-1]),math.atan2(*vl2[:2][::-1])
+
+ ifellipse:
+ a=conic.semi_axis_1
+ b=conic.semi_axis_2
+ returnArcEllipse(a,b,ang1,ang2).ch_cs(cs_lg).translate(*location)
+ radius=conic.radius
+ returnArcCircle(radius,ang1,ang2).ch_cs(cs_lg).translate(*location)
+
+importcopy
+
[docs]defb_spline_curve_with_knots_geometry(b_spline,p1,p2):
+ """
+
+ Currently only clamped b_spline curves and assumed, i. e. closed
+ = False.
+ """
+ control_points=[i.coordinatesforiinb_spline.control_points]
+ # es_near = [vector.isclose(p1, i.coordinates, abs_tol=2.1) for i in b_spline.control_points].index(True)
+ es_near=len(b_spline.control_points)-1-[vector.isclose(p1,i.coordinates,abs_tol=2.1)foriinb_spline.control_points[::-1]].index(True)
+ # ee_near = len(b_spline.control_points) - 1 - [vector.isclose(p2, i.coordinates, abs_tol=2.1) for i in b_spline.control_points[::-1]].index(True)
+ ee_near=[vector.isclose(p2,i.coordinates,abs_tol=2.1)foriinb_spline.control_points].index(True)
+
+ knots=[b_spline.knots[i]foriinrange(len(b_spline.knots))for
+ jinrange(b_spline.knot_multiplicities[i])]
+ # print('bs es, ee in:', es_near, ee_near,
+ # knots[es_near], knots[ee_near+b_spline.degree])
+ # print(' knots, knote:', knots[0], knots[-1], len(knots))
+ ifes_nearisnotNoneandee_nearisnotNone:
+ #print('yes')
+ bs=ArcBSplineCurveWithKnots(
+ b_spline.degree,control_points,b_spline.knot_multiplicities,
+ b_spline.knots,knots[es_near+1],knots[ee_near+b_spline.degree-1])
+ bs._points=[copy.copy(p1)]+bs._points+[copy.copy(p2)]
+ returnbs
+ # +1 so not the last near point but the following, also -1
+ print('error')
+ returnB_spline_curve_with_knots(
+ b_spline.degree,control_points,b_spline.knot_multiplicities,
+ b_spline.knots)
+
+# TODO: backup solution to draw each edge_curve,
+# new is to put edge_curves to edge_loops and draw these loops
+# see data_dict_to_geometry_world
+
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""STEP Standard structure.
+
+:Date: 2020-01-03
+
+.. module:: data_step_std
+ :platform: *nix, Windows
+ :synopsis: STEP Standard structure.
+
+.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
+
+.. seealso::
+ STEP, ISO 10303-21, AP 232 (Application Protocol)
+ http://www.steptools.com/stds/step/ and
+ https://www.steptools.com/stds/stp_aim/html/schema.html
+
+ ISO 10303-21:2002. Industrial automation systems and integration --
+ Product data representation and exchange -- Part 21:
+ Implementation methods: Clear text encoding of the exchange
+ structure
+
+ ISO 10303-21:2016. Industrial automation systems and integration --
+ Product data representation and exchange -- Part 21:
+ Implementation methods: Clear text encoding of the exchange
+ structure
+"""
+# DATA section
+# - Format: Instance name = Entity instance
+# - Example: #4 = PRODUCT_DEFINITION_SHAPE('','',#5);
+# - Instance name
+# - unique name in the form "#1234"
+# - must consist of a positive number
+# - only valid locally within the STEP-file
+# - Entity instance: name of the entity in capital letters followed
+# by attribute values in defined order within parentheses
+# - Attributes
+# - Only explicit attributes get mapped (are listed)
+# - Inverse, Derived and re-declared attributes are not listed
+# since their values can be deduced from the other ones.
+# - Unset attribute values are given as: $
+# - Re-declared attributes as derived in a subtype are encoded: *
+# - Enumeration (ENUM), boolean (BOOLEAN) and logical (LOGICAL)
+# values are given in capital letters with a leading and
+# trailing dot, e. g.: .TRUE.
+# - String values are given as: ''
+# - Integers (INTEGER) and real (REAL) values are used identical
+# to typical programming languages
+# - elements of aggregates (SET, BAG, LIST, ARRAY) are given in
+# parentheses, separated by comma ",":
+# STEP Standard TYPE LIST: first index is 1.
+# STEP Standard TYPE ARRAY: first index is 0.
+
+
[docs]defdimension_of(item):
+ """STEP Standard FUNCTION dimension_of
+
+ :param item: STEP Standard TYPE GEOMETRIC_REPRESENTATION_ITEM
+ :type item: GEOMETRIC_REPRESENTATION_ITEM
+
+ :returns: dim
+ :rtype: int or None
+
+ :ivar dim: STEP Standard TYPE dimension_count (INTEGER).
+ dimension_count > 0
+ :vartype dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_dimension_of.html
+ """
+ # (* SCHEMA step_merged_ap_schema; *)
+ #
+ # -- DIFF IN AP214
+ # -- DIFF IN AP203e2
+ # -- DIFF IN AP238 STEP-NC
+ # -- DIFF IN AP224
+ # -- DIFF IN AP232
+ # FUNCTION dimension_of
+ # (item : geometric_representation_item ) : dimension_count;
+ # LOCAL
+ # x : SET OF representation;
+ # y : representation_context;
+ # dim : dimension_count;
+ # END_LOCAL;
+ # IF 'STEP_MERGED_AP_SCHEMA.CARTESIAN_POINT' IN TYPEOF(item) THEN
+ # dim := SIZEOF(item\cartesian_point.coordinates);
+ # RETURN (dim);
+ # END_IF;
+ # IF 'STEP_MERGED_AP_SCHEMA.DIRECTION' IN TYPEOF(item) THEN
+ # dim := SIZEOF(item\direction.direction_ratios);
+ # RETURN (dim);
+ # END_IF;
+ # IF 'STEP_MERGED_AP_SCHEMA.VECTOR' IN TYPEOF(item) THEN
+ # dim := SIZEOF(item\vector.orientation\direction.direction_ratios);
+ # RETURN (dim);
+ # END_IF;
+ # x := using_representations(item);
+ # IF SIZEOF(x) > 0 THEN
+ # y := x[1].context_of_items;
+ # dim := y\geometric_representation_context.coordinate_space_dimension;
+ # RETURN (dim);
+ # ELSE
+ # RETURN (?);
+ # END_IF;
+ # END_FUNCTION;
+ ifisinstance(item,CARTESIAN_POINT):
+ dim=len(item.coordinates)
+ returndim
+ ifisinstance(item,DIRECTION):
+ dim=len(item.direction_ratios)
+ returndim
+ ifisinstance(item,VECTOR):
+ dim=len(item.orientation.direction_ratios)
+ returndim
+
+ # TODO: x, y
+ # x := using_representations(item);
+ # IF SIZEOF(x) > 0 THEN
+ # y := x[1].context_of_items;
+ # dim := y\geometric_representation_context.coordinate_space_dimension;
+ # RETURN (dim);
+ # ELSE
+ # RETURN (?);
+ # END_IF;
+
+ returnNone
+
+
[docs]deflist_to_array(lis,low,u):
+ """STEP Standard FUNCTION list_to_array
+
+ :param lis: STEP Standard TYPE LIST [0:?] OF GENERIC
+ :type lis: tuple
+ :param low: STEP Standard TYPE INTEGER
+ :type low: int
+ :param u: STEP Standard TYPE INTEGER
+ :type u: int
+
+ :returns: res
+ :rtype: tuple or None
+
+ :param n: STEP Standard TYPE INTEGER
+ :type n: int
+ :ivar res: STEP Standard TYPE ARRAY [low:u] OF GENERIC
+ :vartype res: tuple
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_list_to_array.html
+ """
+ # (* SCHEMA step_merged_ap_schema; *)
+
+ # -- DIFF IN AP214
+ # -- DIFF IN AP203e2
+ # -- DIFF IN AP238 STEP-NC
+ # -- DIFF IN AP224
+ # -- DIFF IN AP232
+ # FUNCTION list_to_array
+ # (lis : LIST [0:?] OF GENERIC : t;
+ # low : INTEGER;
+ # u : INTEGER ) : ARRAY [low:u] OF GENERIC : t;
+ # LOCAL
+ # n : INTEGER;
+ # res : ARRAY [low:u] OF GENERIC : t;
+ # END_LOCAL;
+ # n := SIZEOF(lis);
+ # IF n <> u - low + 1 THEN
+ # RETURN (?);
+ # ELSE
+ # res := [ lis[1]:0 ];
+ # REPEAT i := 2 TO n BY 1;
+ # res[(low + i - 1)] := lis[i];
+ # END_REPEAT;
+ # RETURN (res);
+ # END_IF;
+ # END_FUNCTION;
+ n=len(lis)
+ # length of new array and old list must be equal
+ ifn!=u-low+1:# len(lis) != len(range(low, u+1))
+ returnNone
+
+ # TODO: new list?
+ #res = [i for i in lis]
+ res=lis
+ returnres
+
+
[docs]defboolean_choose(b,choice1,choice2):
+ """STEP Standard FUNCTION boolean_choose
+
+ :param b: STEP Standard TYPE BOOLEAN
+ :type b: bool
+ :param choice1: STEP Standard TYPE GENERIC
+ :type choice1: object
+ :param choice2: STEP Standard TYPE GENERIC
+ :type choice2: object
+
+ :returns: STEP STEP Standard TYPE GENERIC
+ :rtype: object
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_boolean_choose.html
+ """
+ # (* SCHEMA step_merged_ap_schema; *)
+ #
+ # FUNCTION boolean_choose
+ # (b : BOOLEAN;
+ # choice1 : GENERIC : item;
+ # choice2 : GENERIC : item ) : GENERIC : item;
+ # IF b THEN
+ # RETURN (choice1);
+ # ELSE
+ # RETURN (choice2);
+ # END_IF;
+ # END_FUNCTION;
+ returnchoice1ifbelsechoice2
+
+
[docs]defpath_head_to_tail(a_path):
+ """STEP Standard FUNCTION path_head_to_tail
+
+ Check if the path is a connected curve set.
+
+ :param a_path: STEP Standard TYPE path
+ :type a_path: PATH
+
+ :returns: p
+ :rtype: object
+
+ :ivar p: STEP STEP Standard TYPE LOGICAL
+ :vartype item: bool
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_path_head_to_tail.html
+ """
+ # (* SCHEMA step_merged_ap_schema; *)
+
+ # -- DIFF IN AP214
+ # -- DIFF IN AP203e2
+ # -- DIFF IN AP238 STEP-NC
+ # -- DIFF IN AP224
+ # -- DIFF IN AP232
+ # FUNCTION path_head_to_tail
+ # (a_path : path ) : LOGICAL;
+ # LOCAL
+ # n : INTEGER;
+ # p : LOGICAL := TRUE;
+ # END_LOCAL;
+ # n := SIZEOF(a_path.edge_list);
+ # REPEAT i := 2 TO n BY 1;
+ # p := p AND (a_path.edge_list[(i - 1)].edge_end :=: a_path.edge_list[i].edge_start);
+ # END_REPEAT;
+ # RETURN (p);
+ # END_FUNCTION;
+ n=len(a_path.edge_list)
+ p=all([a_path.edge_list[i-1].edge_end==a_path.edge_list[i].edge_startforiinrange(1,n)])
+ returnp
+
+
+
[docs]classREPRESENTATION_ITEM():
+ """STEP Standard ENTITY representation_item
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+
+ Additional attributes
+
+ :ivar idn: for the instance the instance id and for the class the
+ total number of instances
+ :vartype idn: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_representation_item.html
+ """
+ idn=0# equal to total numbers of instances
+
+ def__init__(self,name):
+ self.name=name
+ REPRESENTATION_ITEM.idn+=1
+ self.idn=REPRESENTATION_ITEM.idn# instance id
+
+
[docs]classGEOMETRIC_REPRESENTATION_ITEM(REPRESENTATION_ITEM):
+ """STEP Standard ENTITY geometric_representation_item
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_geometric_representation_item.html
+ """
+ def__init__(self,name):
+ # TODO: or dim rather in a method (or property) so that it is
+ # conducted only on demand?
+ self.dim=dimension_of(self)
+ super().__init__(name)
+
+
[docs]classPOINT(GEOMETRIC_REPRESENTATION_ITEM):
+ """STEP Standard ENTITY point
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_point.html
+ """
+ def__init__(self,name):
+ super().__init__(name)
+
+
[docs]classCARTESIAN_POINT(POINT):
+ """STEP Standard ENTITY cartesian_point
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param coordinates: list of length_measure (floats)
+ :type coordinates: tuple
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_cartesian_point.html
+ """
+ def__init__(self,name,coordinates):
+ self.coordinates=coordinates
+ super().__init__(name)
+
+
[docs]classEDGE(TOPOLOGICAL_REPRESENTATION_ITEM):
+ """STEP Standard ENTITY edge
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param edge_start: start point
+ :type edge_start: VERTEX
+ :param edge_end: end point
+ :type edge_end: VERTEX
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_edge.html
+ """
+ def__init__(self,name,edge_start,edge_end):
+ self.edge_start=edge_start
+ self.edge_end=edge_end
+ super().__init__(name)
+
+
[docs]classCURVE(GEOMETRIC_REPRESENTATION_ITEM):
+ """STEP Standard ENTITY curve
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_curve.html
+ """
+ def__init__(self,name):
+ super().__init__(name)
+
+
[docs]classLINE(CURVE):
+ """STEP Standard ENTITY line
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param pnt:
+ :type pnt: CARTESIAN_POINT
+ :param dir:
+ :type dir: VECTOR
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_line.html
+ """
+ def__init__(self,name,pnt,dir):
+ self.pnt=pnt
+ self.dir=dir
+ super().__init__(name)
+
+
[docs]classSURFACE_CURVE(CURVE):
+ """STEP Standard ENTITY surface_curve
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param curve_3d:
+ :type curve_3d: CURVE
+ :param associated_geometry:
+ :type associated_geometry: list of pcurve_or_surface
+ :param master_representation:
+ :type master_representation: preferred_surface_curve_representation
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+ :param basis_surface:
+ :type basis_surface: SET OF surface
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_surface_curve.html
+ """
+ def__init__(self,name,curve_3d,associated_geometry,master_representation):
+ self.curve_3d=curve_3d
+ self.associated_geometry=associated_geometry
+ self.master_representation=master_representation
+ super().__init__(name)
+
+
[docs]classSEAM_CURVE(SURFACE_CURVE):
+ """STEP Standard ENTITY seam_curve
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param curve_3d:
+ :type curve_3d: CURVE
+ :param associated_geometry:
+ :type associated_geometry: list of pcurve_or_surface
+ :param master_representation:
+ :type master_representation: preferred_surface_curve_representation
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+ :param basis_surface:
+ :type basis_surface: SET OF surface
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_seam_curve.html
+ """
+ def__init__(self,name,curve_3d,associated_geometry,master_representation):
+ super().__init__(name,curve_3d,associated_geometry,master_representation)
+
+
[docs]classEDGE_CURVE(EDGE):
+ """STEP Standard ENTITY edge_curve
+
+ Explicit Attributes
+
+ :param name: STEP Standard TYPE label (STRING)
+ :type name: str
+ :param edge_start: start point
+ :type edge_start: VERTEX
+ :param edge_end: end point
+ :type edge_end: VERTEX
+ :param edge_geometry: curve
+ :type edge_geometry: CURVE
+ :param same_sense: STEP Standard TYPE BOOLEAN
+ :type same_sense: str
+
+ Derived Attributes
+
+ :param dim: STEP Standard TYPE dimension_count (INTEGER)
+ :type dim: int
+
+ Definition from ISO/CD 10303-42:1992: An edge curve is a special subtype of edge which has its geometry fully defined. The geometry is defined by associating the edge with a curve which may be unbounded. As the topological and geometric directions may be opposed, an indicator (same sense) is used to identify whether the edge and curve directions agree or are opposed. The Boolean value indicates whether the curve direction agrees with (TRUE) or is in the opposite direction (FALSE) to the edge direction. Any geometry associated with the vertices of the edge shall be consistent with the edge geometry.
+
+ Informal propositions
+ 1. The domain of the edge curve is formally defined to be the domain of its edge geometry as trimmed by the vertices. This domain does not include the vertices.
+ 2. An edge curve has non-zero finite extent.
+ 3. An edge curve is a manifold.
+ 4. An edge curve is arcwise connected.
+ 5. The edge start is not a part of the edge domain.
+ 6. The edge end is not a part of the edge domain.
+ 7. Vertex geometry shall be consistent with edge geometry.
+
+ Attribute definitions
+ EdgeGeometry
+ The curve which defines the shape and spatial location of the edge. This curve may be unbounded and is implicitly trimmed by the vertices of the edge; this defines the edge domain. Multiple edges can reference the same curve.
+ SameSense
+ This logical flag indicates whether (TRUE), or not (FALSE) the senses of the edge and the curve defining the edge geometry are the same. The sense of an edge is from the edge start vertex to the edge end vertex; the sense of a curve is in the direction of increasing parameter.
+
+ .. seealso::
+ https://www.steptools.com/stds/stp_aim/html/t_edge_curve.html
+ https://iaiweb.lbl.gov/Resources/IFC_Releases/R2x3_final/ifctopologyresource/lexical/ifcedgecurve.htm
+ """
+ def__init__(self,name,edge_start,edge_end,edge_geometry,same_sense):
+ self.edge_geometry=edge_geometry
+ self.same_sense=BOOLEAN_to_bool(same_sense)
+ super().__init__(name,edge_start,edge_end)
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/build/html/_modules/pylib/function.html b/docs/build/html/_modules/pylib/function.html
index df3b3a9..59bcbe4 100644
--- a/docs/build/html/_modules/pylib/function.html
+++ b/docs/build/html/_modules/pylib/function.html
@@ -44,10 +44,12 @@
:synopsis: Mathematical equations... moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
+
+Functions returns function to apply conditions."""importmath
-frompylib.dataimportseq
-frompylib.mathematicsimportlcm
+from.dataimportseq
+from.mathematicsimportlcm
[docs]deftransformation(f,scale_vertical=1,scale_horizontal=1,shift_horizontal=0,shift_vertical=0):
@@ -114,12 +116,13 @@
:results: sine wave function of spatial variable x and optional time t
+ :rtype: function In general, the function is: .. math::
- y(x,t) = A\sin(kx + 2\pi f t + \varphi) + D \\
- y(x,t) = A\sin(kx + \omega t + \varphi) + D
+ y(x,t) = A\sin(kx + \omega t + \varphi) + D \\
+ y(x,t) = A\sin(kx + 2\pi f t + \varphi) + D where:
@@ -178,6 +181,7 @@
:results: sine wave function of spatial variable x and optional time t
+ :rtype: function .. seealso:: :meth:`sine_wave`
@@ -188,12 +192,225 @@
phi=phi+math.pi/2returnsine_wave(A=A,k=k,f=f,phi=phi,D=D,degree=degree)
[docs]defb_spline_knots(control_point_spans,degree=3):
+ """B-spline knots to generate a clamped uniform B-spline curve
+ of degree p (order + 1).
+
+ The internal knots are equally spaced (uniform B-spline curve)
+
+ :param control_point_spans: number of control points + 1
+ :type control_point_spans: int
+ :param degree: degree of B-spline basis functions (default = 3)
+ :type degree: int
+
+ :returns: knot vector
+ :rtype: tuple
+
+ .. seealso::
+ :meth:`b_spline_curve_with_knots`
+ """
+ p=degree
+ n=control_point_spans
+ m=n+p+1# number of knot spans
+
+ # number of
+ U_outer=p+1# at each of the vector
+ U_inner=m+1-2*(U_outer)
+
+ U=[0]*(U_outer)
+ U+=[iforiinrange(1,U_inner)]
+ U+=[U_inner]*(U_outer)
+ returntuple(U)# tuples are hashable
+
+
[docs]defb_spline_curve_with_knots(degree,control_points,knots):
+ """B-spline curve of degree p (order + 1) on a given set of knots.
+
+ n, m and p must satisfy m = n + p + 1.
+
+ :param degree: degree of B-spline basis functions
+ :type degree: int
+ :param control_points: control points P, n + 1 control points
+ :type control_points: list
+ :param knots: Knot vector U. m + 1 non-decreasing numbers / knots,
+ :math:`u_0 <= u_1 <= u_2 <= ... <= u_m`
+ :type knots: list
+
+ :returns: B-spline curve using variable, u \in [u_0, u_m]
+ :rtype: function
+
+ .. math::
+ \mathbf{C}_p(u) = \sum\limits_{i=0}^{n} N_{i,p}(u) \mathbf{P}_i
+
+ * open B-spline curves
+
+ * the curve will not touch the first and last legs of the
+ control polyline
+ * the knot vector does not have any particular structure
+ * for degree p, intervals [u_0, u_p) and [u_{n-p}, u_n) will not
+ have "full support" of basis functions and are ignored when a
+ B-spline curve is open. For open B-spline curves, the domain
+ is inteval [u_p, u_{n-p}]
+
+ * clamped B-spline curves, nonperiodic B-spline curves
+
+ * the curve is tangent to the first and the last legs just like
+ a Bézier curve
+ * the first knot and the last knot must be repeated p+1 times
+ (i. e., of multiplicity p+1)
+
+ * closed B-spline curves
+
+ * the start and the end of the generated curve join together
+ forming a closed loop
+ * repeating some knots and control points # TODO: which?
+
+ * uniform B-spline curves
+
+ * internal knots are equally spaced
+
+ * Bézier curves
+
+ * a B-spline with no internal knots.
+
+ .. seealso::
+ :meth:`b_spline_knots`
+ """
+ dim=len(control_points[0])
+ defC(u):
+ NiPi=[0]*dim
+ foriinrange(len(control_points)):
+ Ni=b_spline_basis(knots,i,degree)
+ forjinrange(dim):
+ NiPi[j]+=Ni(u)*control_points[i][j]
+ returnNiPi
+ returnC
+
+
[docs]defsample_half_open(f,a,b,n=50,endpoint_epsilon=1e-7):
+ # hack to sample close to the endpoint
+ x=seq(a,b,(b-a)/n)+[b-endpoint_epsilon]
+ # Sample the function
+ return[f(xi)forxiinx]
+
+
[docs]defsample_half_open_seq(f,x,endpoint_epsilon=1e-7):
+ # hack to sample close to the endpoint, x[-1] can be present
+ # multiple times.
+ xend=x[-1]
+ x=[xiforxiinxifxi!=xend]+[xend-endpoint_epsilon]
+ # Sample the function
+ return[f(xi)forxiinx]
## Parametric equations# roulette#
+
[docs]defcircle(r):
+ r"""Circle
+
+ :param r: radius of the circle
+ :type r: float
+
+ :results: functions for x of theta and y of theta and the interval
+ :rtype: tuple
+
+ .. math::
+ x(\theta) = r\cos\theta \\
+ y(\theta) = r\sin\theta \\
+ \theta = \left[0, 2\pi\right]
+
+ ::
+
+ * *
+ * r *
+ * *
+ * *
+ * *
+ * *
+
+ >>> x, y = circle(20)[:2]
+ >>> x, y, _ = circle(20)
+ >>> x, y, interval = circle(20)
+ """
+ returnellipse(r,r)
+
+
[docs]defellipse(a,b):
+ r"""Ellipse
+
+ :param a: semi-major axis
+ :type a: float
+ :param b: semi-minor axis
+ :type b: float
+
+ :results: functions for x of theta and y of theta and the interval
+ :rtype: tuple
+
+ .. math::
+ x(\theta) = a\cos\theta \\
+ y(\theta) = b\sin\theta \\
+ \theta = \left[0, 2\pi\right]
+
+ ::
+
+ * .*
+ * b : *
+ * :......*
+ * a *
+ * *
+ * *
+
+ >>> x, y = ellipse(10, 5)[:2]
+ >>> x, y, _ = ellipse(10, 5)
+ >>> x, y, interval = ellipse(10, 5)
+ """
+ x=lambdatheta:a*math.cos(theta)
+ y=lambdatheta:b*math.sin(theta)
+ returnx,y,[0,2*math.pi]
+
[docs]defhypotrochoid(R,r,d):r"""Hypotrochoid
@@ -208,7 +425,7 @@
:param d: distance from the center of the interior circle :type d: float
- :results: functions for x of theta and y of theta
+ :results: functions for x of theta and y of theta and the interval :rtype: tuple .. math::
@@ -223,7 +440,7 @@
* * * * * * * * r **
- * * .... *
+ * * ,.. * * * d * * * ** * * * *
@@ -231,16 +448,16 @@
* * * * *
- >>> x, y = hyotrochoid(20, 6, 6)[:1]
- >>> x, y, theta_end = hyotrochoid(20, 6, 6)
+ >>> x, y = hyotrochoid(20, 6, 6)[:2]
+ >>> x, y, _ = hyotrochoid(20, 6, 6)
+ >>> x, y, interval = hyotrochoid(20, 6, 6) .. seealso:: :meth:`pylib.mathematics.lcm` """x=lambdatheta:(R-r)*math.cos(theta)+d*math.cos((R-r)/r*theta)y=lambdatheta:(R-r)*math.sin(theta)-d*math.sin((R-r)/r*theta)
- theta_end=2*math.pi*lcm(r,R)/R
- returnx,y,theta_end
+ returnx,y,[0,2*math.pi*lcm(r,R)/R]
[docs]defepitrochoid(R,r,d):r"""Epitrochoid
@@ -256,7 +473,7 @@
:param d: distance from the center of the exterior circle :type d: float
- :results: functions for x of theta and y of theta
+ :results: functions for x of theta and y of theta and the interval :rtype: tuple .. math::
@@ -271,7 +488,7 @@
* * * * * * * * * r *
- * ** .... *
+ * ** .., * * ** d * * * * * * * * *
@@ -279,13 +496,13 @@
* * * * *
- >>> x, y = epitrochoid(3, 1, 0.5)[:1]
- >>> x, y, theta_end = epitrochoid(3, 1, 0.5)
+ >>> x, y = epitrochoid(3, 1, 0.5)[:2]
+ >>> x, y, _ = epitrochoid(3, 1, 0.5)
+ >>> x, y, interval = epitrochoid(3, 1, 0.5) """x=lambdatheta:(R+r)*math.cos(theta)-d*math.cos((R+r)/r*theta)y=lambdatheta:(R+r)*math.sin(theta)-d*math.sin((R+r)/r*theta)
- theta_end=2*math.pi
- returnx,y,theta_end
+ returnx,y,[0,2*math.pi]
[docs]defto_str(f,x=None,x_0=0,x_1=1,t=None,h=10,w=80,density=1,char_set="line"):"""Represent functions as string frame with a specific character set.
@@ -299,7 +516,7 @@
:type w: int :param char_set: either "braille" or "block". "braille" uses Unicode
- Characters in the Braille Patterns Block (fisrt index U+2800, last
+ Characters in the Braille Patterns Block (first index U+2800, last index U+28FF [CUDB]_) and the "block" uses part of the Unicode Characters in the Block Elements Block (fisrt index U+2580, last index U+259F [CUDB]_). Alias for braille is line and alias for
@@ -433,7 +650,9 @@
# divide step width of the sequence by 2 (double density, 2 dots/pixel per char)# multiplicate x by 2 (2 dots/pixel per char)forx_iinseq(x_0*window_factor*pixels_horizontal,x_1*window_factor*pixels_horizontal,1/density):
- canvas.set(x_i,f(x_i,t))
+ y_i=f(x_i,t)
+ if0>=y_i>=-h*pixels_vertical:
+ canvas.set(x_i,y_i)#frame = canvas.frame(min_x=a*pixel_per_char, min_y=1, max_x=b*pixel_per_char, max_y=21)frame=canvas.frame()elifchar_setin["histogram","block"]:
diff --git a/docs/build/html/_modules/pylib/geometry.html b/docs/build/html/_modules/pylib/geometry.html
index e4a975f..fd9d3e1 100644
--- a/docs/build/html/_modules/pylib/geometry.html
+++ b/docs/build/html/_modules/pylib/geometry.html
@@ -45,8 +45,8 @@
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
-Affine transforms
------------------
+
+.. rubric:: Affine transformsFunctions in augmented space, in homogenous coordinates.Points are augment to 4 dimensions, by adding a dummy coordinate.
@@ -56,12 +56,21 @@
"""importmathimportcopy
+from.dataimportseqfrom.mathematicsimportvector,matrix
+from.functionimportcircle,ellipse,b_spline_curve_with_knots
+
+
[docs]classPolyline:"""Open and closed wireframe object in local coordinate system This class create its own points (copy).
@@ -113,44 +131,48 @@
self._points=[copy.copy(i)foriinpoints]self.closed=closed
-
[docs]defscale(self,sx,sy=None,sz=None):# if not sy is not suitable because 0 is also falseifsyisNone:sy=sx
@@ -159,28 +181,113 @@
pointinself._points]returnself
[docs]classLine(Wireframe):
- """Line a open wireframe object in local coordinate system"""
+
[docs]classLine(Polyline):
+ """Line, an open wireframe object in local coordinate system"""def__init__(self,point1=Point(-1,0,0),point2=Point(1,0,0)):super().__init__(point1,point2)
-
[docs]classPolygon(Wireframe):
+# TODO: combining wit non Arc version?
+
[docs]classArcCircle(Polyline):
+ """Arc of a circle, an open wireframe object in local coordinate
+ system
+ """
+ def__init__(self,radius=1,ang1=0,ang2=math.pi/2,n=None):
+ x,y,interval=circle(radius)
+ ifnotn:
+ n=Properties.circle_sectors
+ delta=interval[1]/n
+ points=[]
+ points.append(Point(x(ang1),y(ang1),0))
+ ifang1>ang2:
+ ang1=ang1-2*math.pi
+ a,b=int(ang1//delta)+1,int(ang2//delta)+1
+ foriinrange(a,b):
+ points.append(Point(x(i*delta),y(i*delta),0))
+ points.append(Point(x(ang2),y(ang2),0))
+ super().__init__(*points)
+
+# TODO: combining wit non Arc version?
+
[docs]classArcEllipse(Polyline):
+ """Arc of an ellipse, an open wireframe object in local
+ coordinate system
+ """
+ def__init__(self,a=1,b=1,ang1=0,ang2=math.pi/2,n=None):
+ x,y,interval=ellipse(a,b)
+ ifnotn:
+ n=Properties.circle_sectors
+ delta=interval[1]/n
+ points=[]
+ points.append(Point(x(ang1),y(ang1),0))
+ ifang1>ang2:
+ ang1=ang1-2*math.pi
+ a,b=int(ang1//delta)+1,int(ang2//delta)+1
+ foriinrange(a,b):
+ points.append(Point(x(i*delta),y(i*delta),0))
+ points.append(Point(x(ang2),y(ang2),0))
+ super().__init__(*points)
+
+# redefining the .function.sample_half_open(f, a, b, n=50, endpoint_epsilon=1e-7)
+# to create a list of Points
+
[docs]defsample_half_open(f,a,b,n=50,endpoint_epsilon=1e-7):
+ # hack to sample close to the endpoint
+ x=seq(a,b,(b-a)/n)+[b-endpoint_epsilon]
+ # Sample the function
+ return[Point(*f(xi))forxiinx]
+
+# TODO: naming? combining wit non Arc version?
+
[docs]classArcBSplineCurveWithKnots(Polyline):
+ """B-spline curve with knots, an open wireframe object in local
+ coordinate system"""
+ def__init__(self,degree,control_points,knot_multiplicities,
+ knots,start,end,n=5):
+ knots=[knots[i]foriinrange(len(knots))for
+ jinrange(knot_multiplicities[i])]
+ #u = seq(knots[0], knots[-1], (knots[-1]-knots[0])/n) + [knots[-1]-1e-7]
+ C=b_spline_curve_with_knots(degree,control_points,knots)
+ #points = [Point(*C(ui)) for ui in u]
+ points=sample_half_open(C,start,end,n=n,endpoint_epsilon=1e-7)
+ super().__init__(*points)
+
+
[docs]classB_spline_curve_with_knots(Polyline):
+ """B-spline curve with knots, an open wireframe object in local
+ coordinate system"""
+ def__init__(self,degree,control_points,knot_multiplicities,
+ knots,n=5):
+ knots=[knots[i]foriinrange(len(knots))for
+ jinrange(knot_multiplicities[i])]
+ #u = seq(knots[0], knots[-1], (knots[-1]-knots[0])/n) + [knots[-1]-1e-7]
+ C=b_spline_curve_with_knots(degree,control_points,knots)
+ #points = [Point(*C(ui)) for ui in u]
+ points=sample_half_open(C,knots[0],knots[-1],n=n,endpoint_epsilon=1e-7)
+ super().__init__(*points)
+
+
[docs]classPolygon(Polyline):"""Polygon as closed wireframe object in local coordinate system"""def__init__(self,*points):super().__init__(*points,closed=True)
[docs]classCircle(Polygon):
- """Circle a closed wireframe object in local coordinate system"""
- def__init__(self,radius=1,n=10):
- points=[]
- foriinrange(n):
- x=radius*math.cos(i*2*math.pi/n)
- y=radius*math.sin(i*2*math.pi/n)
- points.append(Point(x,y,0))
+ """Circle, a closed wireframe object in local coordinate system"""
+ def__init__(self,radius=1,n=None):
+ x,y,interval=circle(radius)
+ ifnotn:
+ n=Properties.circle_sectors
+ delta=interval[1]/n
+ points=[Point(x(i*delta),y(i*delta),0)foriinrange(n)]
+ super().__init__(*points)
+
+
[docs]classEllipse(Polygon):
+ """Circle, a closed wireframe object in local coordinate system"""
+ def__init__(self,a=1,b=1,n=None):
+ x,y,interval=ellipse(a,b)
+ ifnotn:
+ n=Properties.circle_sectors
+ delta=interval[1]/n
+ points=[Point(x(i*delta),y(i*delta),0)foriinrange(n)]super().__init__(*points)
[docs]classSolid:
@@ -240,6 +347,13 @@
"""Returns the Iterator object"""returniter(self.objects())
[docs]defadd(self,*objects):self._store_init()# calculated values are not correct anymore
+ # [] + [] not possible bc objects are vectors[self._objects.append(i)foriinobjects]returnself
[docs]classtimeit(ContextDecorator):
+ """Meassure time for a function or code block.
+
+ :param description: description for the function or code block
+ used for the print-out
+ :type description: str
+
+ :Example:
+
+ >>> with timeit('section_test'):
+ ... # code
+ section_test took 0.006 ms
+
+ ::
+
+ @timeit('func')
+ def func():
+ # code
+
+ >>> func()
+ func took 0.006 ms
+ """
+ def__init__(self,description=None):
+ self.description=description
+
+ def__enter__(self):
+ self.start_time=time.time()
+ returnself# to use as: with Timit() as t:
+
+ def__exit__(self,*exc):# exc: type, value, traceback
+ elapsed_time_ms=(time.time()-self.start_time)*1000
+ print('{:s} took {:.3f} ms'.format(self.description,elapsed_time_ms))
+ returnFalse
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/build/html/_modules/pylib/mathematics.html b/docs/build/html/_modules/pylib/mathematics.html
index c8f333e..8e78a6a 100644
--- a/docs/build/html/_modules/pylib/mathematics.html
+++ b/docs/build/html/_modules/pylib/mathematics.html
@@ -130,7 +130,7 @@
>>> v[3] 4 """
- # use the list.__getslice__ method and convert result to vector
+ # use the list.__getitem__ method and convert result to vectoritem=super().__getitem__(index)returnvector(item)ifisinstance(item,list)elseitem
@@ -385,12 +385,11 @@
[docs]@staticmethoddeffull(length,fill_value):
- """Returns a vector of length m or matrix of size m rows, n
- columns filled with v.
+ """Returns a vector of length m filled with v. :param length: length of the vector, e. g. 3 :type length: int
- :param fill_value: Fill value
+ :param fill_value: fill value :Type fill_value: scalar :Example:
@@ -403,15 +402,14 @@
[docs]@staticmethoddefzeros(length):
- """Returns a zero vector of length m or matrix of size rows, n
- columns filled with zeros.
+ """Returns a zero vector of length m filled with zeros. :param length: length of the vector, e. g. 3 :type length: int :Example:
- >>> v = zeros(3)
+ >>> v = vector.zeros(3) >>> print(v) [0.0, 0.0, 0.0] """
@@ -419,40 +417,42 @@
[docs]@staticmethoddefones(length):
- """Returns a vector of length m or matrix of size rows, n
- columns filled with ones.
+ """Returns a vector of length m filled with ones. :param length: lhape of the vector, e. g. 3 :type length: int :Example:
- >>> v = ones(3)
+ >>> v = vector.ones(3) >>> print(v) [1.0, 1.0, 1.0] """returnvector.full(length,1.)
[docs]@staticmethod
- defrandom(shape,lmin=0.0,lmax=1.0):
- """Returns a random vector of length n or matrix of size m rows,
- n columns filled with random numbers.
+ defrandom(length,lmin=0.0,lmax=1.0):
+ """Returns a random vector of length n filled with random
+ numbers.
+
+ :param length: lhape of the vector, e. g. 3
+ :type length: int :Example:
- >>> v = random(3)
+ >>> v = vector.random(3) >>> print(v) [0.9172905912930438, 0.8908124278322492, 0.5256002790725927]
- >>> v = random(3, 1, 2)
+ >>> v = vector.random(3, 1, 2) >>> print(v) [1.2563665665080803, 1.9270454509964547, 1.2381672401270487] """importrandomdl=lmax-lmin
- returnvector([dl*random.random()+lminforiinrange(shape)])
+ x=a*b/(abs(a)*abs(b))
+ # decimal floating-point numbers are only approximated by the
+ # binary floating-point numbers actually stored in the machine.
+ # https://docs.python.org/3.8/tutorial/floatingpoint.html
+ xr15=round(x,15)
+ returnmath.acos(xr15)if-1<=xr15<=1elsemath.acos(x)
[docs]defnormalize(self):
+ r"""Normalize a vector (i. e. the vector has a length of 1)
+
+ :type a: vector
+
+ .. math::
+ \mathbf{\hat{a}} = \frac{\mathbf{a}}{|\mathbf{a}|}
+
+ .. seealso::
+ :meth:`__abs__` for a norm (magnitude) of a vector
+ """
+ self[:]=vector.normalized(self)
+ returnself
[docs]defrotate_x(self,theta):r"""Rotation about the x dirction.
@@ -649,8 +675,16 @@
>>> m = matrix([[1, 2, 3, 0], [4, 5, 6, 0], [7, 8, 9, 0], \ [0, 0, 0, 0]])
+ >>> print(m[:])
+ [[1, 2, 3, 0], [4, 5, 6, 0], [7, 8, 9, 0], [0, 0, 0, 0]] >>> print(m[2]) [7, 8, 9, 0]
+ >>> print(m[2, :])
+ [7, 8, 9, 0]
+ >>> print(m[:, 2])
+ [3, 6, 9, 0]
+ >>> print(m[2, 2])
+ 9 >>> print(m[:, 1:3]) [[2, 3], [5, 6], [8, 9], [0, 0]] >>> print(m[0:2, 1:3])
@@ -658,15 +692,143 @@
>>> print(m[::2, ::2]) [[1, 3], [7, 9]] """
+ # TODO single row or column = vector (1d list)?# index: slice(stop), slice(start, stop[, step])# for m[(1,3),:] -> index = ((1, 3), slice(None, None, None))
- # use the list.__getslice__ method and convert result to vector
- try:# 2d slicing (tuple of sclices)
- item=[row.__getitem__(index[1])for
- rowinsuper().__getitem__(index[0])]
- except:# 1d slicing
+ # use the list.__getitem__ method and convert result to matrix
+ #print(index)
+ try:# 2d slicing (tuple of sclices)
+ try:# range:range or range:single: [:, 2]
+ #print(1)
+ item=[row.__getitem__(index[1])for
+ rowinsuper().__getitem__(index[0])]
+ except:# single:range: [2, :], [2, 2]
+ #print(2)
+ item=super().__getitem__(index[0]).__getitem__(index[1])
+ except:# 1d slicing: [:], [2], [2][2]
+ #print(3)item=super().__getitem__(index)
- returnmatrix(item)ifisinstance(item,list)elseitem
[docs]@staticmethod
+ defzeros(m,n):
+ """Returns a zero matrix of size mxn; m rows and n columns
+ filled with zeros.
+
+ :param m: number of rows of the matrix, e. g. 3
+ :type m: int
+ :param n: number of columns of the matrix, e. g. 3
+ :type n: int
+
+ :Example:
+
+ >>> m = matrix.zeros(3, 3)
+ >>> print(m)\
+ [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
+ """
+ returnmatrix([[0.foriinrange(n)]forjinrange(m)])
[docs]defrotate_x(self,theta):r"""Rotation about the x dirction.
diff --git a/docs/build/html/_modules/pylib/numerical/ode.html b/docs/build/html/_modules/pylib/numerical/ode.html
index dc147be..2281546 100644
--- a/docs/build/html/_modules/pylib/numerical/ode.html
+++ b/docs/build/html/_modules/pylib/numerical/ode.html
@@ -35,7 +35,7 @@
Source code for pylib.numerical.ode
#!/usr/bin/env python# -*- coding: utf-8 -*-
-"""Numerical solver of ordinary differential equations.
+r"""Numerical solver of ordinary differential equations.Solves the initial value problem for systems of first orderordinary differential equations.
@@ -47,9 +47,14 @@
:synopsis: Numerical solver... moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
-"""
-from__future__importdivision,print_function
+Approximate the solution :math:`x(t)` of the initial value problem
+
+.. math ::
+ \frac{\mathrm{d}x}{\mathrm{d}t} = \dot{x} &= f(t,x) \\
+ x(t_0) &= x_0 \\
+ t &\in [t_0, t_n]
+"""fromnumpyimportarray,isnan,sum,zeros,dotfromnumpy.linalgimportnorm,inv
@@ -73,20 +78,21 @@
:param verbose: print information (default = False) :type verbose: bool
- Approximate the solution of the initial value problem
+ Approximate the solution :math:`x(t)` of the initial value problem .. math :: \dot{x} &= f(t,x) \\
- x(t_0) &= x_0
+ x(t_0) &= x_0 \\
+ t &\in [t_0, t_n] Choose a value h for the size of every step and set .. math ::
- t_i = t_0 + i h ~,\quad i=1,2,\ldots,n
+ t_{i+1} = t_0 + i h = t_i + h ~,\quad i=0,1,2,\ldots,n-1 The derivative of the solution is approximated as the forward difference equation
-
+
.. math :: \dot{x}_i = f(t_i, x_i) = \frac{x_{i+1} - x_i}{t_{i+1}-t_i}
@@ -166,13 +172,23 @@
the step size, and the global error (error at a given time) is proportional to the step size. """
- x=zeros((len(t),len(x0)))# Preallocate array
- x[0,:]=x0# Initial condition gives solution at first t
- foriinrange(len(t)-1):# Calculation loop
- Dt=t[i+1]-t[i]
- dxdt=array(f(x[i,:],t[i],*p))
- # Approximate solution at next value of x
- x[i+1,:]=x[i,:]+dxdt*Dt
+ frompylib.dataimportissequence
+ ifissequence(x0):
+ x=zeros((len(t),len(x0)))# Preallocate array
+ x[0,:]=x0# Initial condition gives solution at first t
+ foriinrange(len(t)-1):# Calculation loop
+ Dt=t[i+1]-t[i]
+ dxdt=array(f(x[i,:],t[i],*p))
+ # Approximate solution at next value of x
+ x[i+1,:]=x[i,:]+dxdt*Dt
+ else:
+ x=zeros((len(t)))
+ x[0]=x0
+ foriinrange(len(t)-1):# Calculation loop
+ Dt=t[i+1]-t[i]
+ dxdt=array(f(x[i],t[i],*p))
+ # Approximate solution at next value of x
+ x[i+1]=x[i]+dxdt*Dtifverbose:print('Numerical integration of ODE using explicit '+'first-order method (Euler / Runge-Kutta) was successful.')
@@ -218,6 +234,31 @@
...) :param verbose: print information (default = False) :type verbose: bool
+
+ Problem
+
+ .. math ::
+ \dot{y} &= f(t, y) \\
+ y(t_0) &= y_0 \\
+ t &\in [t_0, t_n]
+
+ Increment :math:`\delta t = t_{i+1}-t_i ~,~~ i=0,1,2,\ldots,n-1`
+
+ .. math::
+ y_{n+1} &= y_{i} + \tfrac{1}{6}(
+ \delta y_{i,1} + 2\delta y_{i,2} + 2\delta y_{i,3} +
+ \delta y_{i,4}) \\
+ & \qquad \text{with} \\
+ \delta y_{i,1} &= \delta t \cdot y'(t_{i}, ~ y_{i}) \\
+ \delta y_{i,2} &= \delta t \cdot
+ y'(t_{i}+\tfrac{1}{2}\delta t, ~
+ y_{i}+\tfrac{1}{2}\delta y_{i,1}) \\
+ \delta y_{i,3} &= \delta t \cdot
+ y'(t_{i}+\tfrac{1}{2}\delta t, ~
+ y_{i}+\tfrac{1}{2}\delta y_{i,2}) \\
+ \delta y_{i,4} &= \delta t \cdot
+ y'(t_{i}+\delta t, ~ y_{i}+\delta y_{i,3})
+
"""x=zeros((len(t),len(x0)))# Preallocate arrayx[0,:]=x0# Initial condition
@@ -237,7 +278,7 @@
[docs]deffpi(f,xi,ti,ti1,*p,max_iterations=1000,tol=1e-9,verbose=False):r"""Fixed-point iteration.
-
+
:param f: the function to iterate :math:`f = \dot{x}(x,t)` :type f: function :param xi: initial condition :math:`x_i`
@@ -255,19 +296,19 @@
:type tol: float :param verbose: print information (default = False) :type verbose: bool
-
+
:returns: :math:`x_{i}`
-
+
.. math :: x_{i,j=0} = x_{i}
-
+
.. math :: x_{i,j+1} = x_i + \dot{x}(x_{i,j}, t_{i+1})\cdot(t_{i+1}-t_i)
-
+
.. math :: \text{residuum} = \frac{\lVert x_{i,j+1}-x_{i,j}\rVert} {\lVert x_{i,j+1} \rVert} < \varepsilon
-
+
.. math :: x_{i} = x_{i,j=\text{end}} """
@@ -301,7 +342,7 @@
:type tol: float :param verbose: print information (default = False) :type verbose: bool
-
+
The backward Euler method has order one and is A-stable. """iterations=zeros((len(t),1))
@@ -313,8 +354,9 @@
foriinrange(len(t)-1):Dt=t[i+1]-t[i]xi=x[i,:]
- xi,iteration=fpi(f,xi,t[i],t[i+1],*p,max_iterations,
- tol,verbose)
+ xi,iteration=fpi(f,xi,t[i],t[i+1],*p,
+ max_iterations=max_iterations,tol=tol,
+ verbose=verbose)x[i+1,:]=xiiterations[i]=iterationifverbose:
@@ -382,7 +424,7 @@
dot(dNp,(xp1-xpi))))xp1=xpi+Dt*((1-gamma)*xppi+gamma*xpp11)x1=xi+Dt*xpi+Dt**2*((.5-beta)*xppi+beta*xpp11)
-
+
residuum=norm(xpp11-xpp1)/norm(xpp11)xpp1=xpp11ifresiduum<tol:
@@ -398,10 +440,12 @@
returnx,xp,xpp,iterations
[docs]defnewmark_newtonraphson_mdk(fmdk,x0,xp0,xpp0,t,*p,gamma=.5,beta=.25,max_iterations=1000,tol=1e-9,verbose=False):r"""Newmark method.
+ Using m mass, d damping and k stiffness formulation.
+
:param f: the function to solve :type f: function :param x0: initial condition
@@ -435,9 +479,9 @@
foriinrange(len(t)-1):Dt=t[i+1]-t[i]
- rm,rmx,rmxpp,rd,rdx,rdxp,rk,rkx,f=fnm(x[i,:],
+ rm,rmx,rmxpp,rd,rdx,rdxp,rk,rkx,f=fmdk(x[i,:],xp[i,:],xpp[i,:],t[i],*p)
-
+
xi=x[i,:].reshape(3,1)xpi=xp[i,:].reshape(3,1)xppi=xpp[i,:].reshape(3,1)
@@ -450,7 +494,7 @@
# Approximate solution at next value of x#x11 = x[i,:] + dxdt*Dt
- r=(rmx+rdx+rkx)*Dt**2./4+rdxp*Dt/2+rmxpp
+ r=(rmx+rdx+rkx)*Dt**2./4+rdxp*Dt/2+rmxpprp=f-(rm+dot(rmx,(Dt*xpi+Dt**2./4*xppi))- \
dot(rmxpp,xppi)+ \
rd+dot(rdx,(Dt*xpi+Dt**2./4*xppi))+ \
diff --git a/docs/build/html/_modules/pylib/numerical/ode_model.html b/docs/build/html/_modules/pylib/numerical/ode_model.html
index 5f11cb8..fb71f65 100644
--- a/docs/build/html/_modules/pylib/numerical/ode_model.html
+++ b/docs/build/html/_modules/pylib/numerical/ode_model.html
@@ -37,10 +37,10 @@
# -*- coding: utf-8 -*-"""Mathmatical models governed by ordinary differential equations.
-Describes initial value problems as systems of first order ordinary differential
-equations.
+Describes initial value problems as systems of first order ordinary
+differential equations.
-:Date: 2019-05-25
+:Date: 2020-01-08.. module:: ode_model :platform: *nix, Windows
@@ -48,111 +48,172 @@
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>"""
-from__future__importdivision,print_functionfromnumpyimportarray,cos,sin,dot,squarefromnumpy.linalgimportinv
-
[docs]defdisk(x,t,*p):
- """Rotation of an eccentric disk.
+
[docs]defdisk(d,e,T,method=''):
+ r"""Rotation of an eccentric disk.
- :param x: values of the function
- :type x: list
- :param t: time
- :type t: list
- :param `*p`: parameters of the function
+ :param d: diameter
+ :type d: float
+ :param e: eccentricity
+ :type e: float
+ :param T: torque
+ :type T: float
+ :param method: the method to use, default = ''.
+ :type method:
+ :returns: disk function. This function is independent of the time.
- * diameter
- * eccentricity
- * torque
+ * For method = '': f(x, t=0) -> (xp1, xp2, xp3, xp4, xp5, xp6).
+ x is (x, y, phi, x', y', phi') and the return values are (x',
+ y', phi', x'', y'', phi'')
+ * For method = 'nm': f(xn, xpn, xppn, t=0) -> (N, dN, dNp, dNpp).
+ xn are the values of the function (x, y, phi), xpn are first
+ derivative values of the function (x', y', phi') and xppn are
+ the second derivative values of the function (x'', y'', phi'').
+ The return values are (N, dN, dNp, dNpp)
+ * For method = 'nmmdk': f(xn, xpn, xppn, t=0) ->
+ (rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx, f).
+ xn are the values of the function (x, y, phi), xpn are first
+ derivative values of the function (x', y', phi') and xppn are
+ the second derivative values of the function (x'', y'', phi'').
+ The return values are (rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx,
+ f)
+
+ :rtype: function
+
+ Model
+
+ .. math ::
+ \begin{vmatrix}
+ \ddot{x} + \cos(\varphi)\ddot{\varphi} + 2d \,\dot{x} - \sin(\varphi) \,\dot{\varphi}^2 + 2d\cos(\varphi)\, \dot{\varphi} + x &=&
+ 0 \\
+ \ddot{y} - \sin(\varphi)\ddot{\varphi} + 2d \,\dot{y} - \cos(\varphi) \,\dot{\varphi}^2 + 2d\sin(\varphi)\, \dot{\varphi} + y &=&
+ 0 \\
+ \ddot{\varphi} + e\,y\sin(\varphi) - e\,x\cos(\varphi) &=& t
+ \end{vmatrix}
+ \\
+ \begin{vmatrix}
+ \ddot{x} + \cos(\varphi)\ddot{\varphi} &=&
+ -2d \,\dot{x} + \sin(\varphi) \,\dot{\varphi}^2 -2d\cos(\varphi)\, \dot{\varphi} - x \\
+ \ddot{y} - \sin(\varphi)\ddot{\varphi} &=&
+ -2d \,\dot{y} + \cos(\varphi) \,\dot{\varphi}^2 -2d\sin(\varphi)\, \dot{\varphi} - y \\
+ \ddot{\varphi} &=& t - e\,y\sin(\varphi) + e\,x\cos(\varphi)
+ \end{vmatrix}
+
+ .. math ::
+ \mathbf{M}(\mathbf{x}) \cdot \mathbf{\ddot{x}} &=
+ \mathbf{f}(\mathbf{x}, \mathbf{\dot{x}})
+ \\
+ \begin{bmatrix}
+ 1 & 0 & \cos \varphi \\
+ 0 & 1 & -\sin \varphi \\
+ 0 & 0 & 1
+ \end{bmatrix} \cdot
+ \begin{bmatrix}
+ \ddot{x} \\ \ddot{y} \\ \ddot{\varphi}
+ \end{bmatrix} &= \begin{bmatrix}
+ -2d \,\dot{x} + \sin(\varphi) \,\dot{\varphi}^2 -2d\cos(\varphi)\, \dot{\varphi} - x \\
+ -2d \,\dot{y} + \cos(\varphi) \,\dot{\varphi}^2 -2d\sin(\varphi)\, \dot{\varphi} - y \\
+ t - e\,y\sin(\varphi) + e\,x\cos(\varphi)
+ \end{bmatrix}
+
+
+ returns
+
+ .. math ::
+ x_1 &= x &\quad x_4 &= \dot{x}_1 = \dot{x} &\quad \dot{x}_4 &= \ddot{x} \\
+ x_2 &= y &\quad x_5 &= \dot{x}_2 = \dot{y} &\quad \dot{x}_5 &= \ddot{y} \\
+ x_3 &= \varphi &\quad x_6 &= \dot{x}_3 = \dot{\varphi} &\quad \dot{x}_6 &= \ddot{\varphi} \\
+
+ .. math ::
+ \dot{q} &= f(x) \\
+ \begin{bmatrix}
+ \dot{x}_1 \\
+ \dot{x}_2 \\
+ \dot{x}_3 \\
+ \dot{x}_4 \\
+ \dot{x}_5 \\
+ \dot{x}_6
+ \end{bmatrix} &= \begin{bmatrix}
+ x_4 \\
+ x_5 \\
+ x_6 \\
+ \begin{bmatrix}
+ 1 & 0 & \cos x_3 \\
+ 0 & 1 & -\sin x_3 \\
+ 0 & 0 & 1
+ \end{bmatrix}^{-1} \cdot \begin{bmatrix}
+ -2d \,x_4 + \sin(x_3) \,x_6^2 -2d\cos(x_3)\, x_6 - x_1 \\
+ -2d \,x_5 + \cos(x_3) \,x_6^2 -2d\sin(x_3)\, x_6 - x_2 \\
+ t - e\,x_2\sin(x_3) + e\,x_1\cos(x_3)
+ \end{bmatrix}
+ \end{bmatrix}
+
+ Three explicit differential equations of order 2 reducted to a
+ system of 3x2 first-order differential equations.
+
+ .. seealso::
+ :meth:`pylib.numerical.ode.newmark_newtonraphson` and
+ :meth:`pylib.numerical.ode.newmark_newtonraphson_mdk` """
- qp1=x[3]
- qp2=x[4]
- qp3=x[5]
- M=array([[1,0,cos(x[2])],[0,1,-sin(x[2])],[0,0,1]])
- y=array([[-2*p[0]*x[3]+sin(x[2])*x[5]**2-2*p[0]*cos(x[2])*x[5]-x[0]], \
- [-2*p[0]*x[4]+cos(x[2])*x[5]**2-2*p[0]*sin(x[2])*x[5]-x[1]], \
- [p[2]-p[1]*x[1]*sin(x[2])+p[1]*x[0]*cos(x[2])]])
- qp46=dot(inv(M),y)
- qp4,qp5,qp6=qp46.reshape(-1,).tolist()# 2d array to 1d array to list
- returnqp1,qp2,qp3,qp4,qp5,qp6
-
-
[docs]defdisk_nm(xn,xpn,xppn,t,*p):
- """Rotation of an eccentric disk.
-
- :param xn: values of the function
- :type xn: list
- :param xpn: first derivative values of the function
- :type xpn: list
- :param xppn: second derivative values of the function
- :type xppn: list
- :param t: time
- :type t: list
- :param `*p`: parameters of the function
-
- * diameter
- * eccentricity
- * torque
- """
- N=array([[xppn[0]+cos(xn[2])*xppn[2]+2*p[0]*xpn[0]+2*p[0]*cos(xn[2])*xpn[2]-sin(xn[2])*square(xpn[2])+xn[0]],
- [xppn[1]-sin(xn[2])*xppn[2]+2*p[0]*xpn[1]-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])+xn[1]],
- [xppn[2]+p[1]*(-cos(xn[2])*xn[0]+sin(xn[2])*xn[1])-p[2]]])
- dN=array([[1,0,-sin(xn[2]*xppn[2])-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
- [0,1,-cos(xn[2]*xppn[2])-2*p[0]*cos(xn[2])*xpn[2]+sin(xn[2])*square(xpn[2])],
- [-p[1]*cos(xn[2]),p[1]*cos(xn[2]),p[1]*(sin(xn[2])*xn[0]+cos(xn[2])*xn[1])]])
- dNp=array([[2*p[0],0,2*p[0]*cos(xn[2])-2*sin(xn[2])*xpn[2]],
- [0,2*p[0],-2*p[0]*sin(xn[2])-2*cos(xn[2])*xpn[2]],
- [0,0,0]])
- dNpp=array([[1,0,cos(xn[2])],
- [0,1,-sin(xn[2])],
- [0,0,1]])
- returnN,dN,dNp,dNpp
-
-
[docs]defdisk_nmmdk(xn,xpn,xppn,t,*p):
- """Rotation of an eccentric disk.
-
- :param xn: values of the function
- :type xn: list
- :param xpn: derivative values of the function
- :type xpn: list
- :param xppn: second derivative values of the function
- :type xppn: list
- :param t: time
- :type t: list
- :param `*p`: parameters of the function
-
- * diameter
- * eccentricity
- * torque
- """
- rm=array([[xppn[0]+cos(xn[2])*xppn[2]],
- [xppn[1]-sin(xn[2])*xppn[2]],
- [xppn[2]]])
- rmx=array([[0,0,-sin(xn[2]*xppn[2])],
- [0,0,-cos(xn[2]*xppn[2])],
- [0,0,0]])
- rmxpp=array([[1,0,cos(xn[2])],
- [0,1,-sin(xn[2])],
- [0,0,1]])
- rd=array([[2*p[0]*xpn[0]+2*p[0]*cos(xn[2])*xpn[2]-sin(xn[2])*square(xpn[2])],
- [2*p[0]*xpn[1]-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
- [0]])
- rdx=array([[0,0,-2*p[0]*sin(xn[2])*xpn[2]-cos(xn[2])*square(xpn[2])],
- [0,0,-2*p[0]*cos(xn[2])*xpn[2]+sin(xn[2])*square(xpn[2])],
- [0,0,0]])
- rdxp=array([[2*p[0],0,2*p[0]*cos(xn[2])-2*sin(xn[2])*xpn[2]],
- [0,2*p[0],-2*p[0]*sin(xn[2])-2*cos(xn[2])*xpn[2]],
- [0,0,0]])
- rk=array([[xn[0]],
- [xn[1]],
- [p[1]*(-cos(xn[2])*xn[0]+sin(xn[2])*xn[1])]])
- rkx=array([[1,0,0],
- [0,1,0],
- [-p[1]*cos(xn[2]),p[1]*cos(xn[2]),p[1]*(sin(xn[2])*xn[0]+cos(xn[2])*xn[1])]])
- f=array([[0],[0],[p[2]]])
- returnrm,rmx,rmxpp,rd,rdx,rdxp,rk,rkx,f
diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv
index af114d8..4bb359d 100644
Binary files a/docs/build/html/objects.inv and b/docs/build/html/objects.inv differ
diff --git a/docs/build/html/py-modindex.html b/docs/build/html/py-modindex.html
index c076c06..7ac03f1 100644
--- a/docs/build/html/py-modindex.html
+++ b/docs/build/html/py-modindex.html
@@ -42,6 +42,7 @@
d |
f |
g |
+ h |
i |
m |
o |
@@ -58,6 +59,16 @@
1st read a STEP file.
+2nd convert header and data section string to list of commands.
+
The STEP file string can have commands distributed over several
+lines, the commands are seperated by ;\n. This class un-wraps
+each command into one line (remove \n) and removes empty lines.
ISO 10303-21:2002. Industrial automation systems and integration –
+Product data representation and exchange – Part 21:
+Implementation methods: Clear text encoding of the exchange
+structure
+
ISO 10303-21:2016. Industrial automation systems and integration –
+Product data representation and exchange – Part 21:
+Implementation methods: Clear text encoding of the exchange
+structure
dim (int) – STEP Standard TYPE dimension_count (INTEGER)
+
+
+
Definition from ISO/CD 10303-42:1992: An edge curve is a special subtype of edge which has its geometry fully defined. The geometry is defined by associating the edge with a curve which may be unbounded. As the topological and geometric directions may be opposed, an indicator (same sense) is used to identify whether the edge and curve directions agree or are opposed. The Boolean value indicates whether the curve direction agrees with (TRUE) or is in the opposite direction (FALSE) to the edge direction. Any geometry associated with the vertices of the edge shall be consistent with the edge geometry.
+
+
Informal propositions
+
The domain of the edge curve is formally defined to be the domain of its edge geometry as trimmed by the vertices. This domain does not include the vertices.
+
An edge curve has non-zero finite extent.
+
An edge curve is a manifold.
+
An edge curve is arcwise connected.
+
The edge start is not a part of the edge domain.
+
The edge end is not a part of the edge domain.
+
Vertex geometry shall be consistent with edge geometry.
+
+
+
Attribute definitions
+
EdgeGeometry
The curve which defines the shape and spatial location of the edge. This curve may be unbounded and is implicitly trimmed by the vertices of the edge; this defines the edge domain. Multiple edges can reference the same curve.
+
+
SameSense
This logical flag indicates whether (TRUE), or not (FALSE) the senses of the edge and the curve defining the edge geometry are the same. The sense of an edge is from the edge start vertex to the edge end vertex; the sense of a curve is in the direction of increasing parameter.
the curve will not touch the first and last legs of the
+control polyline
+
the knot vector does not have any particular structure
+
for degree p, intervals [u_0, u_p) and [u_{n-p}, u_n) will not
+have “full support” of basis functions and are ignored when a
+B-spline curve is open. For open B-spline curves, the domain
+is inteval [u_p, u_{n-p}]
sine wave function of spatial variable x and optional
time t
+
Return type
+
function
+
In general, the function is:
-\[\begin{split}y(x,t) = A\sin(kx + 2\pi f t + \varphi) + D \\
-y(x,t) = A\sin(kx + \omega t + \varphi) + D\end{split}\]
+\[\begin{split}y(x,t) = A\sin(kx + \omega t + \varphi) + D \\
+y(x,t) = A\sin(kx + 2\pi f t + \varphi) + D\end{split}\]
where:
@@ -246,7 +457,7 @@ which are normed to the range of [0, 1] to
h (int) – number of chars in vertical direction
w (int) – number of chars in horizontal direction
char_set (str) – either “braille” or “block”. “braille” uses Unicode
-Characters in the Braille Patterns Block (fisrt index U+2800, last
+Characters in the Braille Patterns Block (first index U+2800, last
index U+28FF [CUDB]) and the “block” uses part of the Unicode
Characters in the Block Elements Block (fisrt index U+2580, last
index U+259F [CUDB]). Alias for braille is line and alias for
diff --git a/docs/build/html/pylib.geometry.html b/docs/build/html/pylib.geometry.html
index 3861f74..4b7d0c6 100644
--- a/docs/build/html/pylib.geometry.html
+++ b/docs/build/html/pylib.geometry.html
@@ -42,16 +42,47 @@
Functions in augmented space, in homogenous coordinates.
Points are augment to 4 dimensions, by adding a dummy coordinate.
For points the dummy coordinate is always normalized to 1.
With homogenous coordinates translation of points is repesentable
as a linear transformation.
xppn (list) – second derivative values of the function
-
t (list) – time
-
*p –
parameters of the function
-
-
diameter
-
eccentricity
-
torque
-
-
+
Returns
+
disk function. This function is independent of the time.
+
+
For method = ‘’: f(x, t=0) -> (xp1, xp2, xp3, xp4, xp5, xp6).
+x is (x, y, phi, x’, y’, phi’) and the return values are (x’,
+y’, phi’, x’‘, y’‘, phi’‘)
+
For method = ‘nm’: f(xn, xpn, xppn, t=0) -> (N, dN, dNp, dNpp).
+xn are the values of the function (x, y, phi), xpn are first
+derivative values of the function (x’, y’, phi’) and xppn are
+the second derivative values of the function (x’‘, y’‘, phi’‘).
+The return values are (N, dN, dNp, dNpp)
+
For method = ‘nmmdk’: f(xn, xpn, xppn, t=0) ->
+(rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx, f).
+xn are the values of the function (x, y, phi), xpn are first
+derivative values of the function (x’, y’, phi’) and xppn are
+the second derivative values of the function (x’‘, y’‘, phi’‘).
+The return values are (rm, rmx, rmxpp, rd, rdx, rdxp, rk, rkx,
+f)