Last change of this documentation page: 2022-06-02 of SolidGeometry 3.9
SGTBB(SG)- replaces the complex surface geometry by a simplified bounding box

SGTBB(SG)% SGTBB(SG) - replaces the complex surface geometry by a simplified bounding box
% (by Tim Lueth, VLFL-Lib, 2017-JUN-29 as class: KINEMATICS AND FRAMES)
%
% Since SG can be very large structures, the call by value concept of
% matlab is time consuming. This fnctn replaces the solid geometries by
% its bounding box geometries relative to the base frame.
% in Contrast to SGofBB or BBofSG this fnctn handles in addition the
% frames that are required for cinematic chains (Status of: 2017-07-02)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGTchain, SGTcalibchain, iscollofSG
%
% SGbb=SGTBB(SG)
% === INPUT PARAMETERS ===
% SG: cell list of solid geometries
% === OUTPUT RESULTS ======
% SGbb: cell list of bounding boxes
%
% See also: SGTchain, SGTcalibchain, iscollofSG
%
%
% Copyright 2017 Tim C. Lueth

SGTframeChain_39(nums,extr,B,F)- returns a list of frame connections for a cell list if solids

SGTframeChain_39(nums,extr,B,F)% SGTframeChain_39(nums,extr,B,F) - returns a list of frame connections for a cell list if solids
% (by Tim Lueth, VLFL-Lib, 2017-JUN-26 as class: KINEMATICS AND FRAMES)
%
% Auxiliary fnctn called from SGTchain. The funxtion can be used to
% create a frame-link-table of cell elements. The frame-link-table format
% is
% [BaseNr FFrame-SG1ind BFrame-SG2ind SG1ind SG2ind rot2nd ztr2nd]
% BaseNr: Nr of SG in the final cell list; 0=origin
% FFrame: Namestring of first (SG1ind) element's frame
% BFrame: Namestring of second (SG2ind) element's frame
% SG1ind: Index of first element in Geometry List SGc
% SG2ind: Index of second element in Geometry List SGc
% rot2nd: z-Rotation wrt to ez of BFrame of second element
% ztr2nd: z-translation wrt to ez of BFrame of second element
% (Status of: 2019-06-26)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGTframeChain, SGTBB, SGTcalibchain, SGTchain, SGTplot, SGTui
%
% [LFrm,LL,Chstr]=SGTframeChain_39(nums,[extr,B,F])
% === INPUT PARAMETERS ===
% nums: number, or list of chain elements
% extr: optional chaining; default is i-F -> i+1-B
% B: extra chaining [SG1ind FFrame SG2ind BFrame] such as [1 'F' 2 'B']
% F: Standard Base frame string; default is 'B'
% === OUTPUT RESULTS ======
% LFrm: Link Frame Tabe
% LL: Link list [start index , End index] in SGc
% Chstr: compiled string like the extra chaining
%
% EXAMPLE:
% SGTframeChain(6)
% SGTframeChain(1:3,'','BX','FX')
% SGTframeChain(1:3,[3 'F' 4 'B'],'BX','FX')
% SGTframeChain(1:7,[7 'F1' 8 'B' 7 'F2' 8 'B' 7 'F3' 8 'B']);
%
% See also: SGTframeChain, SGTBB, SGTcalibchain, SGTchain, SGTplot, SGTui
%
%
% Copyright 2017-2019 Tim C. Lueth

SGTframeChain(nums,extr,B,F)- returns a list of frame connections for a cell list if solids

SGTframeChain(nums,extr,B,F)% SGTframeChain(nums,extr,B,F) - returns a list of frame connections for a cell list if solids
% (by Tim Lueth, VLFL-Lib, 2017-JUN-26 as class: KINEMATICS AND FRAMES)
%
% Auxiliary fnctn called from SGTchain. The funxtion can be used to
% create a frame-link-table of cell elements. The frame-link-table format
% is
% [BaseNr FFrame-SG1ind BFrame-SG2ind SG1ind SG2ind]
% BaseNr: Nr of SG in the final cell list; 0=origin
% FFrame: Namestring of first (SG1ind) element's frame
% BFrame: Namestring of second (SG2ind) element's frame
% SG1ind: Index of first element in Geometry List SGc
% SG2ind: Index of second element in Geometry List SGc
%
% (Recommendation by Simon Schiele)
% NEW FORMAT IN SG-LIB 4.7 (MANDATORY FOR MORE THAN 31 ELEMENTS): Use {}
% instead of [];
% Instead: [SG1ind FFrame SG2ind BFrame] such as [1 'F' 2 'B']
% now use: {SG1ind FFrame SG2ind BFrame} such as {1 'F' 2 'B'} (Status
% of: 2019-06-26)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGTchain
%
% [LFrm,LL,CCstr]=SGTframeChain(nums,[extr,B,F])
% === INPUT PARAMETERS ===
% nums: number, or list of chain elements
% extr: extra chaining [SG1ind FFrame SG2ind BFrame] such as [1 'F' 2 'B']
% B: Standard Base frame string; default is 'B'
% F: Standard follower frame string; default is 'F'
% === OUTPUT RESULTS ======
% LFrm: Link Frame Tabe
% LL: Link list [start index , End index] in SGc
% CCstr: compiled string like the extra chaining
%
% EXAMPLE:
% SGTframeChain(6)
% SGTframeChain(1:3,'','BX','FX')
% SGTframeChain(1:3,[3 'F' 4 'B'],'BX','FX')
% SGTframeChain(1:7,[7 'F1' 8 'B' 7 'F2' 8 'B' 7 'F3' 8 'B'])
% SGTframeChain(1:7,{7 'F1' 8 'B' 7 'F2' 8 'B' 7 'F3' 8 'B'}) % New format required for 32 or more elements
%
% See also: SGTchain
%
%
% Copyright 2017-2019 Tim C. Lueth

SGTsetorigin(SG,Nam)- moves the solid into a position that the base frame become the origin

SGTsetorigin(SG,Nam)% SGTsetorigin(SG,Nam) - moves the solid into a position that the base frame become the origin
% (by Tim Lueth, VLFL-Lib, 2017-JUN-26 as class: SURFACES)
%
% The position of the vertices and of the frames are moved
% Since it is a robotics kinematic fnctn, the frame is turned with 'z'
% downwards. IN case that you need the expecte match ('matchT') use '-'
% before the frame otherwise it is the 'alignT' condition. (Status of:
% 2020-09-04)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGtransT, SGTget, SGtransrelSG, SGtransrelT
%
% SGN=SGTsetorigin(SG,Nam)
% === INPUT PARAMETERS ===
% SG: Solid geometry
% Nam: Name of a frame or ez vector
% === OUTPUT RESULTS ======
% SGN: spatial transformed SG
%
% EXAMPLE:
% loadweb JACO_robot.mat
% SGTsetorigin(JCF,'B') % z-vector is downwards - equivalent to 'alignT' with eye(4)
% SGTsetorigin(JCF,'-B') % z=vector is upwards - equivalent to 'matchT' with eye(4)
%
%
% See also: SGtransT, SGTget, SGtransrelSG, SGtransrelT
%
%
% Copyright 2017-2020 Tim C. Lueth

SGpuzzlecut3D(SG,bsiz)- creates from a large solid geometry smaller printable parts

SGpuzzlecut3D(SG,bsiz)% SGpuzzlecut3D(SG,bsiz) - creates from a large solid geometry smaller printable parts
% (by Tim Lueth, VLFL-Lib, 2017-JUN-25 as class: SURFACES)
%
% This fnctn helps to separate large Solids in smaller ones for printing
% or for half-cuts of technical education (Status of: 2018-08-21)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGcutrecursivly, SGsurfaceplot, SGwriteSeparatedSTL
%
% SGs=SGpuzzlecut3D(SG,[bsiz])
% === INPUT PARAMETERS ===
% SG: Solid Geometry
% bsiz: [maxx maxy maxz]; if values are <=1 it is not the size but divider
% === OUTPUT RESULTS ======
% SGs: List of puzzle elements
%
% EXAMPLE:
% load JACO_robot.mat
% SGpuzzlecut3D(JC6,[0.5 0.5 0.5]);
% % h=patchofgca; setplotlight(h,'r',1)
%
% See also: SGcutrecursivly, SGsurfaceplot, SGwriteSeparatedSTL
%
%
% Copyright 2017-2021 Tim C. Lueth

isplanarVLFL(VL,FL,thre)- return whether a point cloud or surface is planar

isplanarVLFL(VL,FL,thre)% isplanarVLFL(VL,FL,thre) - return whether a point cloud or surface is planar
% (by Tim Lueth, VLFL-Lib, 2017-JUN-25 as class: SURFACES)
%
% works with VL or VL/FL (Status of: 2017-06-25)
%
% Introduced first in SolidGeometry 3.9
%
% See also: isconvexPL
%
% [r,m]=isplanarVLFL(VL,[FL,thre])
% === INPUT PARAMETERS ===
% VL: Vertex List
% FL: optional Facet List to accelerate
% thre: Optional threshold; default is 1e-2 ~ 1%
% === OUTPUT RESULTS ======
% r: true if planar, i.e. m% m: maximal z value / size(BB)
%
% See also: isconvexPL
%
%
% Copyright 2017 Tim C. Lueth

VLFLofSGTsurface(SG,N,t,d,s)- returns the flange surface for a given T matrix frame name

VLFLofSGTsurface(SG,N,t,d,s)% VLFLofSGTsurface(SG,N,t,d,s) - returns the flange surface for a given T matrix frame name
% (by Tim Lueth, VLFL-Lib, 2017-JUN-25 as class: SURFACES)
%
% calls fnctn SGofSurface with the surfaces of Frame N (Status of:
% 2018-10-31)
%
% Introduced first in SolidGeometry 3.9
%
% See also: isplanarVLFL, SGofSurface, SGofSGTsurface
%
% [SVL,SFL]=VLFLofSGTsurface(SG,[N,t,d,s])
% === INPUT PARAMETERS ===
% SG: Solid Geometry
% N: Name of Frame
% t: thickness of the solid; default is 0.5
% d: distance from the surface; default is 0.3
% s: streching of the border line; default is 0
% === OUTPUT RESULTS ======
% SVL: Vertex List
% SFL: Facet List
%
% EXAMPLE:
% load JACO_robot.mat
% X=SGTui(JC01,'T',1);
% VLFLofSGTsurface(X,'T')
%
% See also: isplanarVLFL, SGofSurface, SGofSGTsurface
%
%
% Copyright 2017-2018 Tim C. Lueth

NLconformance(NVL,ez);- changes the orientation of a list of normal vectors

NLconformance(NVL,ez);% NLconformance(NVL,ez); - changes the orientation of a list of normal vectors
% (by Tim Lueth, VLFL-Lib, 2017-JUN-25 as class: ANALYTICAL GEOMETRY)
%
% in case that a vector has a relative angle of more than 90 degree
% (pi/2) to ez, it is turned in direction (multiplied with -1
% Used in TR3mountingfaces
% (Status of: 2017-07-26)
%
% Introduced first in SolidGeometry 3.9
%
% See also: NLcontourVL
%
% NVL=NLconformance(NVL,ez);
% === INPUT PARAMETERS ===
% NVL: Normal vector list
% ez: reference direction vector.
% === OUTPUT RESULTS ======
% NVL: Correct normal vector list
%
% See also: NLcontourVL
%
%
% Copyright 2017-2018 Tim C. Lueth

cellstrfind(cellstr,str)- returns the position of a string in a cell list of string

cellstrfind(cellstr,str)% cellstrfind(cellstr,str) - returns the position of a string in a cell list of string
% (by Tim Lueth, VLFL-Lib, 2017-JUN-25 as class: AUXILIARY PROCEDURES)
%
% Introduced first in SolidGeometry 3.9
%
% See also: cell2str, str2cell, cell2array
%
% f=cellstrfind(cellstr,str)
% === INPUT PARAMETERS ===
% cellstr: cellstr
% str: search string
% === OUTPUT RESULTS ======
% f: array of position for each cell elememt
%
% EXAMPLE:
% x={'ax','ab','ac'}
% cellstrfind(x,'c')
%
% See also: cell2str, str2cell, cell2array
%
%
% Copyright 2017 Tim C. Lueth

CVLofRL(RL,ez)%- returns a CVL of a radial list and an ez vector

CVLofRL(RL,ez)%% CVLofRL(RL,ez)% - returns a CVL of a radial list and an ez vector
% (by Tim Lueth, VLFL-Lib, 2017-JUN-22 as class: ANALYTICAL GEOMETRY)
%
% This fnctn can be used to postprocess an Radial list of
% TR3mountingfaces or CVLdimclassifier
% RL has the format:
% [xc yc zc r n deg xs ys zs]
% [xc yc zc] is the center of the circle
% r is the radius
% n is the number of found point
% deg is the angle of the circle segment
% [xs yz zs] can be either a sample point or the norm vector
% (Status of: 2017-06-25)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CVLdimclassifier, TR3mountingfaces, SGTui
%
% CVL=CVLofRL(RL,[ez])%
% === INPUT PARAMETERS ===
% RL: Radial list
% ez: optional ez vector; or ez vector list list
% === OUTPUT RESULTS ======
% CVL: Closed Vertex List
%
% EXAMPLE:
% SG=SGtransR(SGsample(25),rot(pi/6,0,pi/2));
% TR3=triangulation(SG.FL,SG.VL);
% [a,b,c,d,e]=TR3mountingfaces(TR3,23,1); show
% CVL=CVLofRL(e,b); SGfigure; SGplot(SG); CVLplot(CVL);
%
% See also: CVLdimclassifier, TR3mountingfaces, SGTui
%
%
% Copyright 2017 Tim C. Lueth

JACOstruct- creates a global struct JACOs that is used by JACOsim, JACOget, JACOset

JACOstruct% JACOstruct - creates a global struct JACOs that is used by JACOsim, JACOget, JACOset
% (by Tim Lueth, ROBOT-Lib, 2017-JUN-20)
%
% To use the global JACO struct, insert the following line into your
% fnctn:
%
% global JACOs; JACOstruct; % Useage of global JACO robot struct
%
% It consist of:
% JACOs.SG=SGreduceVLFL(JACO,3000); % Geometry of JACO
% JACOs.HG={}; % Geometry of obstacles
% JACOs.speed=1; % Robot speed
% JACOs.bus=81; % Robot USB address
% JACOs.hj=[]; % handle for drawing of robot
% JACOs.hh=[]; % handle for environment drawing
% JACOs.phi=[0 0 0 0 0 0 0 0 0]; % current Position
% JACOs.path=[]; % current path
% (Status of: 2017-06-21)
%
% Introduced first in SolidGeometry 3.9
%
% See also: JACOget, JACOset, JACOsim
%
% JACOstruct
%
% EXAMPLE: inspect struct and current values
% global JACOs; JACOstruct; % Useage of global JACO robot struct
% JACOs
%
% See also: JACOget, JACOset, JACOsim
%
%
% Copyright 2017 Tim C. Lueth

opponentFL(FL,fii)- returns the opponents indices for a facet list

opponentFL(FL,fii)% opponentFL(FL,fii) - returns the opponents indices for a facet list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-19 as class: SURFACES)
%
% NOT WELL TESTED YET! (Status of: 2017-06-19)
%
% Introduced first in SolidGeometry 3.9
%
% OiL=opponentFL(FL,[fii])
% === INPUT PARAMETERS ===
% FL: Facet list
% fii: optional index of facet
% === OUTPUT RESULTS ======
% OiL: opponent of vertex i in facet fii
%
%
% Copyright 2017 Tim C. Lueth

JACOset(CMD,PVAL)- sets parameter of the real JACO robot and of the global JACO model

JACOset(CMD,PVAL)% JACOset(CMD,PVAL) - sets parameter of the real JACO robot and of the global JACO model
% (by Tim Lueth, ROBOT-Lib, 2017-JUN-19)
%
% Introduced first in SolidGeometry 3.9
%
% See also: JACOget, JACOsim
%
% [ANSW,t]=JACOset([CMD,PVAL])
% === INPUT PARAMETERS ===
% CMD: Command string
% PVAL: Parameter Values als cell or numeric value
% === OUTPUT RESULTS ======
% ANSW:
% t:
%
% See also: JACOget, JACOsim
%
%
% Copyright 2017 Tim C. Lueth

JACOsim(CMD,PVAL)- Simulates the behaviour of the JACO robot

JACOsim(CMD,PVAL)% JACOsim(CMD,PVAL) - Simulates the behaviour of the JACO robot
% (by Tim Lueth, ROBOT-Lib, 2017-JUN-19)
%
% This fnctn is used to simulate the behavior of the JACO robot which is
% helpful for visualization and collision detection and creating the
% programatically interface of JACOget and JACOset and JACOstruc.
% JACOsim supports the following commands:
% 'init' = sets the JACOstruct to a predefined pose and 'shows' it
% 'joints',phi = changes JACOStruct if the pose is collision free
% 'show' = plots the pose of the joint values of JACOstruct
% 'shows',phi = plots the pose of the given joint values
% 'safe',{SG,'under'} = defines safety zones relative to JACO
% 'stl', SGs = modifies the kinematic chain/geometry of the robot
% JACOsim without an parameter => JACOsim('show') (Status of: 2017-06-21)
%
% Introduced first in SolidGeometry 3.9
%
% See also: JACOget, JACOset, JACOstruct
%
% [ANSW,t]=JACOsim([CMD,PVAL])
% === INPUT PARAMETERS ===
% CMD: command string
% PVAL: Parameter Values als cell or numeric value
% === OUTPUT RESULTS ======
% ANSW:
% t:
%
% EXAMPLE:
% JACOsim('init') % Sets the simulation to a initial pose
% JACOsim('safe',{A,'alignbottom','infront',-200,'left',0}) % safety zone
% JACOsim,('stl',SG) % modifies the kinematic chain/geometry of the robot
%
% See also: JACOget, JACOset, JACOstruct
%
%
% Copyright 2017 Tim C. Lueth

nearestcluster(RL,lim)- returns a reduced list of points and a cluster list

nearestcluster(RL,lim)% nearestcluster(RL,lim) - returns a reduced list of points and a cluster list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-18 as class: ANALYTICAL GEOMETRY)
%
% Finds cluster of points with a minimal distance of lim;
% draws a result only for [nx2 and nx3]
% (Status of: 2018-08-20)
%
% Introduced first in SolidGeometry 3.9
%
% See also: nearestpair, connectofmat, nearestpair, VLnearestNeighbor
%
% [RLn,Rn]=nearestcluster(RL,lim)
% === INPUT PARAMETERS ===
% RL: Point list
% lim: maximum distance for clustering
% === OUTPUT RESULTS ======
% RLn: Points list with replaced mean values
% Rn: Cluster matrix related to RL
%
% EXAMPLE:
% [a,b]=nearestcluster(rand(5,2),0.25)
% nearestcluster(rand(500,2),0.05);
%
% See also: nearestpair, connectofmat, nearestpair, VLnearestNeighbor
%
%
% Copyright 2017-2021 Tim C. Lueth

nofcolmap(col)- returns a number instead of a color string

nofcolmap(col)% nofcolmap(col) - returns a number instead of a color string
% (by Tim Lueth, VLFL-Lib, 2017-JUN-17 as class: USER INTERFACE)
%
% colmap='kbgcrmyw';
% unfortunately, there is a fnctn color of matlab and tim lueth
% The colors are extended by values such as
% (l)ight, (d)eep, (a)algea, (o)range, (p)purple
% (Status of: 2022-01-29)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGshowcolors, color, VLcol, colofn, colofPose
%
% col=nofcolmap(col)
% === INPUT PARAMETERS ===
% col: color integer od string
% === OUTPUT RESULTS ======
% col: number of color
%
% EXAMPLE:
% colofn('2')
% nofcolmap('r')
% nofcolmap('o') % Orange
% nofcolmap('lb') % light blue
% nofcolmap('dp') % deep purple
%
% See also: SGshowcolors, color, VLcol, colofn, colofPose
%
%
% Copyright 2017-2022 Tim C. Lueth

SGreduceVLFL(SG,f)- returns a solid with reduced

SGreduceVLFL(SG,f)% SGreduceVLFL(SG,f) - returns a solid with reduced
% (by Tim Lueth, VLFL-Lib, 2017-JUN-17 as class: SURFACES)
%
% speed optimized; uses reducepatch.
% can be used to reduce facet related to the original vertex list (Status
% of: 2017-08-08)
%
% Introduced first in SolidGeometry 3.9
%
% See also: reducepatch, findVL, SGretesselate, nofVLFL, SGfacenum,
% SGdelaunay
%
% [SG,FL,vi]=SGreduceVLFL(SG,[f])
% === INPUT PARAMETERS ===
% SG: Original Solid Geometry
% f: reduction factor or number of facets per
% === OUTPUT RESULTS ======
% SG: SG with reduced vertices and facets
% FL: Facet List related to original solid geometry (slows down by findVL)
% vi: index of new vertices related to original solid geometry
%
% EXAMPLE:
% a=SGsample(17); a=SGstripfields(a)
% SGreduceVLFL(a,800)
% SGreduceVLFL(a,0.5)
% [~,FL]=SGreduceVLFL(a,0.1), VLFLplot(a.VL,FL)
%
% See also: reducepatch, findVL, SGretesselate, nofVLFL, SGfacenum,
% SGdelaunay
%
%
% Copyright 2017 Tim C. Lueth

sofBB(SG,minv)- returns the maximal dimension of the bounding box

sofBB(SG,minv)% sofBB(SG,minv) - returns the maximal dimension of the bounding box
% (by Tim Lueth, VLFL-Lib, 2017-JUN-17 as class: AUXILIARY PROCEDURES)
%
% Useful fnctn for some SG plot fnctn (Status of: 2019-03-24)
%
% Introduced first in SolidGeometry 3.9
%
% See also: zofBB, BBofCPL, BBofSG, BBofVL, sofgca
%
% [ms,s,cp,bb]=sofBB(SG,[minv])
% === INPUT PARAMETERS ===
% SG: VL oder SG or BB
% minv: optional minimal value; default is 0
% === OUTPUT RESULTS ======
% ms: max dimension
% s: [sx,sy,sz]
% cp: center point of BB
% bb: BB of SG
%
% EXAMPLE:
% sofBB(SGsample(1))
% sofBB(VLsample(4))
% sofBB(BBofCPL(PLcircle(5)))
% A=SGsample(25); [~,b,c]=sofBB(A), SGfigure; SGplot(A); view(-30,30); bplot(c,b,'m--');
%
% See also: zofBB, BBofCPL, BBofSG, BBofVL, sofgca
%
%
% Copyright 2017-2022 Tim C. Lueth

setplotlight(hi,col,alpha);- changes the alpha value of a given graphics object handle

setplotlight(hi,col,alpha);% setplotlight(hi,col,alpha); - changes the alpha value of a given graphics object handle
% (by Tim Lueth, VLFL-Lib, 2017-JUN-16 as class: VISUALIZATION)
%
% Similar to VLFLplotlight, but sets the parameter individually for a
% patch handle
% In case of just setting the alpha values use: alpha (Status of:
% 2020-07-03)
%
% Introduced first in SolidGeometry 3.9
%
% See also: alpha, VLFLplotlight, rotate3dlight
%
% setplotlight(hi,[col,alpha]);
% === INPUT PARAMETERS ===
% hi: patch handle
% col: color value or letter; optional
% alpha: alpha index
%
% EXAMPLE:
% SGfigure; [~,~,h]=SGsurfaceplot(SGsample(20)); view(-30,30);
% setplotlight(h,'',0.4); show
% setplotlight(h,'b',0.4); show
%
%
%
% See also: alpha, VLFLplotlight, rotate3dlight
%
%
% Copyright 2017-2020 Tim C. Lueth

rcmod1(n,cx,sq)- return rows and colum for a given number and col length

rcmod1(n,cx,sq)% rcmod1(n,cx,sq) - return rows and colum for a given number and col length
% (by Tim Lueth, VLFL-Lib, 2017-JUN-16 as class: AUXILIARY PROCEDURES)
%
% Useful for subplot indi (Status of: 2017-06-16)
%
% Introduced first in SolidGeometry 3.9
%
% See also: mod1, modn
%
% rc=rcmod1(n,cx,[sq])
% === INPUT PARAMETERS ===
% n: index
% cx: number of cols
% sq: if true; cx is the length of a squared field; default is false
% === OUTPUT RESULTS ======
% rc: [row col] =[1... 1...]
%
% See also: mod1, modn
%
%
% Copyright 2017 Tim C. Lueth

SGTcalibchain(SGs,phi,Fram)- changes the base frames of a set of solid geoemtries

SGTcalibchain(SGs,phi,Fram)% SGTcalibchain(SGs,phi,Fram) - changes the base frames of a set of solid geoemtries
% (by Tim Lueth, VLFL-Lib, 2017-JUN-16 as class: KINEMATICS AND FRAMES)
%
% This fnctn is useful if frames such as base frame or follower frame
% were originally created manually from the STL files using SGTui but the
% real frames have other orientations.
% In this case, the fnctn SGTchain shows only the right pose for a set of
% angles if an angle offset if added. If this offset angle is known, the
% real configuration can be shown by SGTchain(offset) using the offset
% angles.
% To avoid the offset angle it is possible to calibrate the z axis of the
% Base frame or the follower frame. (Status of: 2017-06-16)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGTchain
%
% SGn=SGTcalibchain(SGs,[phi,Fram])
% === INPUT PARAMETERS ===
% SGs: Set of solids, with base and folloer frame
% phi: offset angle for the
% Fram: Frame name; default is 'B'
% === OUTPUT RESULTS ======
% SGn: Set of solids, with turned frames
%
% EXAMPLE:
% load JACO_robot.mat
% SGTchain(JACO,[[0 0 -90 +180 +90 180 180]]/180*pi); view(-160,0); %
% shows the zeros pose using an offset
% X=SGTcalibchain(JACO,[[0 0 -90 +180 +90 180 180]]/180*pi) % turns the
% base frames
% SGTchain(X,[0 0 0 0 0 0 0])
% SGTchain(X,[0 0 180 180 0 0 0]/180*pi); view(-160,0)
%
% See also: SGTchain
%
%
% Copyright 2017 Tim C. Lueth

iscollofSG(SGA,SGB,full,firstc,shape);- calculate collision vertices of two solids or a solid chain

iscollofSG(SGA,SGB,full,firstc,shape);% iscollofSG(SGA,SGB,full,firstc,shape); - calculate collision vertices of two solids or a solid chain
% (by Tim Lueth, VLFL-Lib, 2017-JUN-14 as class: KINEMATICS AND FRAMES)
%
% If result is empty; there is no collision
% In case of (Status of: 2017-07-26)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGreduceVLFL, VLcrossingSG, SGseparate, SGSurfaces,
% SGanalyzePenetration, SGanalyzeGroupParts
%
% res=iscollofSG(SGA,[SGB,full,firstc,shape]);
% === INPUT PARAMETERS ===
% SGA: Solid A
% SGB: Solid B; if empty SGA is used
% full: true=full FL; false=Bounding box; default is false
% firstc: true = stops after first crossings; false=complete; default=true
% shape: if true; bounding boxe is relative to base frame; default=true
% === OUTPUT RESULTS ======
% res: List of crossing points
%
% See also: SGreduceVLFL, VLcrossingSG, SGseparate, SGSurfaces,
% SGanalyzePenetration, SGanalyzeGroupParts
%
%
% Copyright 2017-2018 Tim C. Lueth

isSG(SG)- return whether an object is a Solid Geometry

isSG(SG)% isSG(SG) - return whether an object is a Solid Geometry
% (by Tim Lueth, VLFL-Lib, 2017-JUN-14 as class: SURFACES)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGisempty, isconvexPL, isPL
%
% res=isSG(SG)
% === INPUT PARAMETERS ===
% SG: Object
% === OUTPUT RESULTS ======
% res: result
%
% EXAMPLE:
% isSG(PLcircle(4))
% isSG(SGofCPLz(PLcircle(4),2))
%
% See also: SGisempty, isconvexPL, isPL
%
%
% Copyright 2017-2022 Tim C. Lueth

SGTchain(SGs,phi,z,nums,extr,B,F)- returns the spatial transformed solids of a kinematic chain

SGTchain(SGs,phi,z,nums,extr,B,F)% SGTchain(SGs,phi,z,nums,extr,B,F) - returns the spatial transformed solids of a kinematic chain
% (by Tim Lueth, VLFL-Lib, 2017-JUN-14 as class: KINEMATICS AND FRAMES)
%
% If no extra parameters are used, all connections are done using 'B'
% Base frame and 'F' Follower Frame
% The first rotation is currently ignored and can be called using NaN or
% zeros. i.e. the base frame of the first element is always unchanged.
% The parameter nums, extr, B and F are identical to SGTframechain to
% define a the frame chain
% for improved reaing and debugging it is possible to create a frame
% chain once and use it as parameter nums
%
% ATTENTION THE FORMAT FOR THE EXTRA CHAINING DID CHANGE IN SG-Lib 4.7
% FROM CHAR TO CELL
% Instead: [SG1ind FFrame SG2ind BFrame] such as [1 'F' 2 'B']
% now use: {SG1ind FFrame SG2ind BFrame} such as {1 'F' 2 'B'}
% (Status of: 2019-06-26)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGTframeChain, SGTBB, SGTcalibchain, SGTplot, SGTui
%
% SGn=SGTchain(SGs,[phi,z,nums,extr,B,F])
% === INPUT PARAMETERS ===
% SGs: Cell list of n Solid Geometries
% phi: vector of length n of radial rotations around the F-z frame
% z: optional z value in ez direction
% nums: optional chaining; nums can also be SGTframechain
% extr: extra chaining [SG1ind FFrame SG2ind BFrame] such as [1 'F' 2 'B']
% B: Standard Base frame string; default is 'B'
% F: Standard follower frame string; default is 'F'
% === OUTPUT RESULTS ======
% SGn: Cell list of n spatial transformed Solid Geometries
%
% EXAMPLE:
% loadweb('JACO_robot.mat')
% JACO={JC0,JC1,JC2,JC3,JC4,JC5,JC6}
% SGfigure; SGplot(JACO); view(-30,30); show
% SGTchain(JACO,[NaN pi/2]);
% SGTchain(JACO,[NaN pi/1 pi/2 pi/3 pi/4 pi/5 pi/6]);
%
% a=JACOget('joints',1:6)
% SGTchain(JACO,[+[NaN a]+[0 0 -90 +180 +90 180 180]]/180*pi); view(-160,0)
% ad=[-90 160 44 90 90 90]/180*pi; SGTchain(JACO,[NaN ad]); view(-160,0);
%
% Fchain=SGTframeChain(1:7,[7 'F' 8 'B' 7 'F2' 8 'B' 7 'F3' 8 'B'])
% SGTchain(JACO,[NaN pi/2 pi pi],+100,Fchain)
%
%
% See also: SGTframeChain, SGTBB, SGTcalibchain, SGTplot, SGTui
%
%
% Copyright 2017-2019 Tim C. Lueth

JACOget(CMD,PVAL)- returns information on the JACO robot by direct calls

JACOget(CMD,PVAL)% JACOget(CMD,PVAL) - returns information on the JACO robot by direct calls
% (by Tim Lueth & Samuel Detzel, ROBOT-Lib, 2017-JUN-13)
%
% Commands are processed sequentially.
% Therefor, if a specific jaco is called, use:
% JACOget('jaco',2,'joints',1:6) to get the first six joints of jaco
% Current commands are:
% 'jaco' = number of jaco = [1...16]
% 'joints' = get joint values = [1:9] (Status of: 2017-06-13)
%
% Introduced first in SolidGeometry 3.9
%
% See also: PEAKinstall, JACOset, JACOsim
%
% [ANSW,t]=JACOget([CMD,PVAL])
% === INPUT PARAMETERS ===
% CMD: Command string
% PVAL: Numeric Parameter Values
% === OUTPUT RESULTS ======
% ANSW: Answer
% t: time delay between call and answer
%
% EXAMPLE: Get information on the current joints of jaco #1
% JACOget('joints',1:3)
% JACOget('jaco',2,'joints',1:9,'jaco',1,'joints',1:4)
%
% See also: PEAKinstall, JACOset, JACOsim
%
%
% Copyright 2017 Tim C. Lueth

SGof2CPLzbranch(CPLA,CPLB,z,stype,ctype)- Creates a Solid for an 1:n or n:1 solid branch

SGof2CPLzbranch(CPLA,CPLB,z,stype,ctype)% SGof2CPLzbranch(CPLA,CPLB,z,stype,ctype) - Creates a Solid for an 1:n or n:1 solid branch
% (by Tim Lueth, VLFL-Lib, 2017-JUN-12 as class: SURFACES)
%
% =======================================================================
% OBSOLETE (2021-03-29) - USE 'SGof2CPLzcorrelate' INSTEAD
% =======================================================================
%
% USED BY SGof2CPLzcorrelate
% Creates a 1:n or n:1 solid branch.
% Either CPLA or CPLB must consist of ONLY ONE contour (Status of:
% 2020-09-23)
%
% Introduced first in SolidGeometry 3.9
%
% See also: [ SGof2CPLzcorrelate ] ; SGof2CPLz, SGof2CPLsz,
% SGof2CPLzheurist
%
% [SG,NFLW,NFLA,NFLB]=SGof2CPLzbranch([CPLA,CPLB,z,stype,ctype])
% === INPUT PARAMETERS ===
% CPLA: Contour A
% CPLB: Contour B
% z: height or [height separation]; default is 0.5
% stype: "number", "length", "angle", "center"; default is "length"
% ctype: "mina" or "miny"; default is "mina"
%
% === OUTPUT RESULTS ======
% SG: Solid Geometry of the branch
% NFLW: Wall Facets
% NFLA: Bottom Facets
% NFLB: Cover Facets
%
% EXAMPLE:
% SGof2CPLzbranch(CPLsample(2), CPLsample(9),50)
% SGof2CPLzbranch(CPLsample(6), CPLsample(10),50)
% SGof2CPLzbranch(CPLsample(6), CPLsample(10),[50 0.9])
% SGof2CPLzbranch(CPLaddauxpoints(CPLsample(6),1), CPLaddauxpoints(CPLsample(10),1),[50 0.9])
% SGof2CPLzbranch(CPLselectinout(CPLsample(38),[1 10]),CPLselectinout(CPLsample(39),[1 10]),10);
%
% See also: [ SGof2CPLzcorrelate ] ; SGof2CPLz, SGof2CPLsz,
% SGof2CPLzheurist
%
%
% Copyright 2017-2021 Tim C. Lueth

SGof2CPLzheurist(CPLA,CPLB,z,stype,ctype)- EXPERIMENT to show the connection of two contours

SGof2CPLzheurist(CPLA,CPLB,z,stype,ctype)% SGof2CPLzheurist(CPLA,CPLB,z,stype,ctype) - EXPERIMENT to show the connection of two contours
% (by Tim Lueth, VLFL-Lib, 2017-JUN-11 as class: SURFACES)
%
% This fnctn is the same as SGof2CPLsz but supports more than one
% contour! The optimal result depends on the expectations of the user.
% Consider different options for stype carefully:
% "number" of points, i.e. 1:nmax
% "length" of contour, i.e. 0:sum(edge length)
% "angle" of contour, i.e. 0:sum(abs(edge angle))
% "center" of contour, i.e. 0:360 degree
% also the starting point ctype ('rot' or 'min');
% Quite optimal procedure to find the walls between two planar contours
% without adding new points. The number of faces is na+nb.
% The resulting vertex list SG:
% SG.VL=[VLaddz(CPA,0);VLaddz(CPB,z)];
% SG.FL=[FLA;FLB;FLW];
% (Status of: 2017-06-12)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGof2CPLz, SGof2CPLsz, SGof2CPLzbranch, SGanalyzeGroupParts,
% SGseparate, SGanalyzePenetration
%
% [SG,NFW,FLA,FLB,CC,LA,LB]=SGof2CPLzheurist([CPLA,CPLB,z,stype,ctype])
% === INPUT PARAMETERS ===
% CPLA: Contour A
% CPLB: Contour B
% z: height z
% stype: "number", "length", "angle", "center"; default is "length"
% ctype: "mina" or "miny"; default is "mina"
% === OUTPUT RESULTS ======
% SG: New Vertex List
% NFW: New Wall List
% FLA: New Bottom FL
% FLB: New TOP FL
% CC: Correspondance list
% LA: Index of Contours A in NVL
% LB: Index of Contours B in NVL
%
% EXAMPLE:
% SGof2CPLzheurist(CPLsample(14), CPLsample(26),'','angle');
%
% See also: SGof2CPLz, SGof2CPLsz, SGof2CPLzbranch, SGanalyzeGroupParts,
% SGseparate, SGanalyzePenetration
%
%
% Copyright 2017 Tim C. Lueth

ELofCIL(CIL,cl)- Converts a Contour Index List into an Edge list

ELofCIL(CIL,cl)% ELofCIL(CIL,cl) - Converts a Contour Index List into an Edge list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-11 as class: AUXILIARY PROCEDURES)
%
% Contour index list [start index end index; start index end index ,...]
% (Status of: 2017-06-11)
%
% See also: ELofn, CILofEL
%
% EL=ELofCIL(CIL,[cl])
% === INPUT PARAMETERS ===
% CIL: Contour index list [start index end index; start end ,...]
% cl: closing; default is true
% === OUTPUT RESULTS ======
% EL: Edge List
%

delaunayofCPL(CPLB)- more sharp delaunay triangulation in 2D (planar case)

delaunayofCPL(CPLB)% delaunayofCPL(CPLB) - more sharp delaunay triangulation in 2D (planar case)
% (by Tim Lueth, VLFL-Lib, 2017-JUN-11 as class: CLOSED POLYGON LISTS)
%
% The delaunayTriangulation fnctn an be used to create a convex enclosing
% facet. On the other hand, this convex contour also includes facets,
% which are not necessary to enclose the original contours.
% The fnctn also provides the edge list of the constricting contour.
% (Status of: 2020-08-16)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CPLconvexhull, CPLconvexhulldelaunay, CPLharbour, CPLfillin,
% CPLfillinside, CPLfillgap
%
% [TR3,oi,nfi,fi,EL]=delaunayofCPL(CPLB)
% === INPUT PARAMETERS ===
% CPLB: Closed Contour List
% === OUTPUT RESULTS ======
% TR3: delaunayTriangulation
% oi: removed facets from outside
% nfi: outside facets
% fi: fi=isInterior(TR3)
%
% EL: Edge List of the
%
% EXAMPLE:
% CPLB=[CPLsample(7)+[-25 0];NaN NaN;CPLsample(7)+[0 10];NaN NaN;PLstar(10)+[50 0]];
% [PL,EL]=PLELofCPL(CPLB); TR=delaunayTriangulation(PL,EL); SGfigure; TRplot(TR)
% delaunayofCPL(CPLB); % better version
%
% See also: CPLconvexhull, CPLconvexhulldelaunay, CPLharbour, CPLfillin,
% CPLfillinside, CPLfillgap
%
%
% Copyright 2017-2020 Tim C. Lueth

VLofCVL(CVL)- creates a Contour index list for a CPL/CVL

VLofCVL(CVL)% VLofCVL(CVL) - creates a Contour index list for a CPL/CVL
% (by Tim Lueth, VLFL-Lib, 2017-JUN-10 as class: CLOSED POLYGON LISTS)
%
% This is in fact the same fnctn as CILofCVL which is called in this
% fnctn.
% (Status of: 2017-06-10)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CVLofVLCIL
%
% [VL,CIL,EL]=VLofCVL(CVL)
% === INPUT PARAMETERS ===
% CVL: CLosed Polygon list CPL/CVL
% === OUTPUT RESULTS ======
% VL: Vertex list without doubles and NaNs
% CIL: Contour index list related to VL
% EL:
%
% EXAMPLE:
% [VL,CIL]=VLofCVL(CPLsample(26))
%
% See also: CVLofVLCIL
%

CILofCVL(CPL)- creates a Contour index list for a CPL/CVL

CILofCVL(CPL)% CILofCVL(CPL) - creates a Contour index list for a CPL/CVL
% (by Tim Lueth, VLFL-Lib, 2017-JUN-10 as class: CLOSED POLYGON LISTS)
%
% [CILC,VL,CIL]=CILofCVL(CPL)
% === INPUT PARAMETERS ===
% CPL: CLosed Polygon list CPL/CVL
% === OUTPUT RESULTS ======
% CILC: Contour index list related to CPL
% VL: Vertex list without doubles and NaNs
% CIL: Contour index list related to VL
%
% EXAMPLE:
% [CILC,VL,CIL]=CILofCVL(CPLsample(26))
%

cellofNaN(CVL)- converts a CVL/CPL into a cell list

cellofNaN(CVL)% cellofNaN(CVL) - converts a CVL/CPL into a cell list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-10 as class: AUXILIARY PROCEDURES)
%
% Introduced first in SolidGeometry 3.9
%
% See also: selectNaN, lengthNaN, replaceNaN, separateNaN, uniqueNaN,
% unsortNaN
%
% VLcell=cellofNaN(CVL)
% === INPUT PARAMETERS ===
% CVL: CVL/CPL separated by NaN
% === OUTPUT RESULTS ======
% VLcell: Cell list of separated PL/CVL
%
% EXAMPLE:
% cellofNaN(CPLsample(26))
% cellofNaN(CPLsample(27))
%
% See also: selectNaN, lengthNaN, replaceNaN, separateNaN, uniqueNaN,
% unsortNaN
%
%
% Copyright 2017-2019 Tim C. Lueth

CVLofVLCIL(VL,CIL)- returns a CPL/CVL from a PL or VL using a contour index list

CVLofVLCIL(VL,CIL)% CVLofVLCIL(VL,CIL) - returns a CPL/CVL from a PL or VL using a contour index list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-09 as class: CLOSED POLYGON LISTS)
%
% CIL= [startindex endindex; startindex endindex; ]
% (Status of: 2017-06-09)
%
% See also: PLofCPL, CPLofPL, CILofCVL
%
% CVL=CVLofVLCIL(VL,CIL)
% === INPUT PARAMETERS ===
% VL: Point or Vertex list
% CIL: [startindex endindex; startindex endindex; ]
% === OUTPUT RESULTS ======
% CVL: CLosed Polygon List or Closed Vertex List
%
% EXAMPLE:
% VL=rand(6,3)
% CVLofVLCIL(VL,[1 3;4 6])
%

reversesortindex(iO)- returns the reverse sort index for a sort index

reversesortindex(iO)% reversesortindex(iO) - returns the reverse sort index for a sort index
% (by Tim Lueth, VLFL-Lib, 2017-JUN-09 as class: AUXILIARY PROCEDURES)
%
% rO=sortrows([iO [1:size(iO)]']); rO=rO(:,2); (Status of: 2020-08-22)
%
% Introduced first in SolidGeometry 3.9
%
% See also: maprows, findVL, VLFLreorder, VLcorrelate
%
% rO=reversesortindex(iO)
% === INPUT PARAMETERS ===
% iO: result of sortrows
% === OUTPUT RESULTS ======
% rO: reverse sort order
%
% EXAMPLE:
% A=SGbox([30 20 10]);
% VL=A.VL, [VL,a]=sortrows(VL), b=reversesortindex(a)
% SGfigure; VLFLplot(VL,b(FL),'y');
%
% See also: maprows, findVL, VLFLreorder, VLcorrelate
%
%
% Copyright 2017-2020 Tim C. Lueth

exp_2017_06_07(CPLA,CPLB,z)- EXPERIMENT to show the connection of two contours => SGof2CPLzheurist

exp_2017_06_07(CPLA,CPLB,z)% exp_2017_06_07(CPLA,CPLB,z) - EXPERIMENT to show the connection of two contours => SGof2CPLzheurist
% (by Tim Lueth, VLFL-Lib, 2017-JUN-08 as class: EXPERIMENTS)
%
% This fnctn is the same as SGof2CPLz but supports more than one contour!
% The optimal result depends on the expectations of the user. Consider
% different options for stype carefully:
% "number" of points, i.e. 1:nmax
% "length" of contour, i.e. 0:sum(edge length)
% "angle" of contour, i.e. 0:sum(abs(edge angle))
% "center" of contour, i.e. 0:360 degree
% also the starting point ctype ('rot' or 'min');
% Quite optimal procedure to find the walls between two planar contours
% without adding new points. The number of faces is na+nb.
% The resulting vertex list SG:
% SG.VL=[VLaddz(CPA,0);VLaddz(CPB,z)];
% SG.FL=[FLA;FLB;FLW];
% (Status of: 2017-06-12)
%
% [NVL,NFW,FLA,FLB,CC,LA,LB]=exp_2017_06_07([CPLA,CPLB,z])
% === INPUT PARAMETERS ===
% CPLA: Contour A
% CPLB: Contour B
% z: height z
% === OUTPUT RESULTS ======
% NVL: New Vertex List
% NFW: New Wall List
% FLA: New Bottom FL
% FLB: New TOP FL
% CC: Correspondance list
% LA: Index of Contours A in NVL
% LB: Index of Contours B in NVL
%
% EXAMPLE:
% [VL,FL,FLB,FLB,CC,LA,LB]=exp_2017_06_07(CPLsample(12),CPLsample(13))
%

maxmax(A)- returns the maximal maximum of a multidimensional matrix

maxmax(A)% maxmax(A) - returns the maximal maximum of a multidimensional matrix
% (by Tim Lueth, VLFL-Lib, 2017-JUN-05 as class: AUXILIARY PROCEDURES)
%
% =======================================================================
% OBSOLETE (2017-06-05) - USE FAMILY 'max(D(:))' INSTEAD
% =======================================================================
%
% See also: [ max(D(:)) ] ; maxmax, minmin
%
% M=maxmax(A)
% === INPUT PARAMETERS ===
% A: matrix
% === OUTPUT RESULTS ======
% M: largest maximum of A
%
% EXAMPLE:
% maxmax(rand(2,2,2))
%

minmin(A)- returns the minimal minum of a multidimensional matrix

minmin(A)% minmin(A) - returns the minimal minum of a multidimensional matrix
% (by Tim Lueth, VLFL-Lib, 2017-JUN-05 as class: AUXILIARY PROCEDURES)
%
% =======================================================================
% OBSOLETE (2017-06-05) - USE FAMILY 'min(D(:))' INSTEAD
% =======================================================================
%
% See also: [ min(D(:)) ] ; maxmax
%
% M=minmin(A)
% === INPUT PARAMETERS ===
% A: matrix
% === OUTPUT RESULTS ======
% M: min(min(.....
%
% EXAMPLE:
% minmin(rand(2,2,2))
%

removeimat(D,r,c)- removes a row and a column of a indexed matrix

removeimat(D,r,c)% removeimat(D,r,c) - removes a row and a column of a indexed matrix
% (by Tim Lueth, VLFL-Lib, 2017-JUN-05 as class: AUXILIARY PROCEDURES)
%
% See also: imat
%
% ND=removeimat(D,r,c)
% === INPUT PARAMETERS ===
% D: indexed matrix
% r: row to delete
% c: column to delete
% === OUTPUT RESULTS ======
% ND: Matrix without this column and row
%
% EXAMPLE:
% D=imat(rand(3,5)), removeimat(D,1,2)
%

imat(D)- returns a matrix including row column and column row

imat(D)% imat(D) - returns a matrix including row column and column row
% (by Tim Lueth, VLFL-Lib, 2017-JUN-05 as class: AUXILIARY PROCEDURES)
%
% See also: imat, removeimat
%
% DN=imat(D)
% === INPUT PARAMETERS ===
% D: matrix 2x2
% === OUTPUT RESULTS ======
% DN: matrix plus row column and column row
%
% EXAMPLE:
% D=imat(rand(3,5))
%

textCVL (CVL,c,s,nt,lb)- plots descriptors for each contour into a figure using text command

textCVL (CVL,c,s,nt,lb)% textCVL (CVL,c,s,nt,lb) - plots descriptors for each contour into a figure using text command
% (by Tim Lueth, VLFL-Lib, 2017-JUN-05 as class: VISUALIZATION)
%
% up to 99 contours are marked at the first point by a letter and a
% number (Status of: 2017-07-27)
%
% Introduced first in SolidGeometry 3.9
%
% See also: textT, textP, textVL, textVLFL
%
% textCVL(CVL,[c,s,nt,lb])
% === INPUT PARAMETERS ===
% CVL: Contour list separated by Nan (CPL/CVL)
% c: Color, default is black
% s: Size, default is 16
% nt: optional list of selected contours
% lb: optional string for text; default is 'C'
%
% EXAMPLE: Different examples for plotting
% SGfigure; CPL=CPLsample(12); CVLplot(CPL); textCVL(CPL);
%
% See also: textT, textP, textVL, textVLFL
%
%
% Copyright 2017 Tim C. Lueth

nearestpair(PLA,PLB,tp);- returns the nearest point pairs of two vector list

nearestpair(PLA,PLB,tp);% nearestpair(PLA,PLB,tp); - returns the nearest point pairs of two vector list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-04 as class: ANALYTICAL GEOMETRY)
%
% Two vector list are processed using the norm distance. If the parameter
% 'unique' is used, then e vector that was used already cannot be used a
% second time. The index zero shows that there is no corresponding vector
% in the second list
% For the points that could win the nearast pair race get the nearest
% point as partner in a second list
% (Status of: 2021-12-10)
%
% Introduced first in SolidGeometry 3.9
%
% See also: plist, nearestcluster, connectofmat, norm, PLcorrelate,
% CPLcorrelate, VLnearestNeighbor
%
% [p,x,D,pn]=nearestpair(PLA,PLB,[tp]);
% === INPUT PARAMETERS ===
% PLA: Vector list A
% PLB: Vector list B
% tp: 'min', 'mean' ; default is 'min'
% === OUTPUT RESULTS ======
% p: [Ai Bi] index list for the exclusive pairs
% x: Distance between the pairs
% D: Full Distance matrix
% pn: [Ai Bi] index list for the unpaired points
%
% EXAMPLE:
% D1=rand(10,2); D2=rand(10,2);
% nearestpair(D1,D2,'mean');
% nearestpair(D1,D2,'min');
% D1=rand(10,2); D2=rand(5,2);
% nearestpair(D1,D2,'min')
% nearestpair(D2,D1,'min')
%
% See also: plist, nearestcluster, connectofmat, norm, PLcorrelate,
% CPLcorrelate, VLnearestNeighbor
%
%
% Copyright 2017-2021 Tim C. Lueth

circshiftCPL(CPL,n,pl)- returns a circular shifted CPL

circshiftCPL(CPL,n,pl)% circshiftCPL(CPL,n,pl) - returns a circular shifted CPL
% (by Tim Lueth, VLFL-Lib, 2017-JUN-04 as class: CLOSED POLYGON LISTS)
%
% This is more or less for testing CPLcorrelate (Status of: 2019-06-19)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CPLcircshift
%
% CPL=circshiftCPL(CPL,[n,pl])
% === INPUT PARAMETERS ===
% CPL: Closed Polygon List
% n: number of circshifts polygon; default is random
% pl: if true; the individul contours are shifted; default is false
% === OUTPUT RESULTS ======
% CPL: resulting CPL
%
% EXAMPLE:
% SGfigure; B=circshiftCPL(CPLsample(13),123) ;CVLplot(circshiftCPL(B));
% SGfigure; B=circshiftCPL(CPLsample(14),1000) ;CVLplot(circshiftCPL(B));
% SGfigure; circshiftCPL(CPLsample(12),-1); B=ans
% SGfigure; circshiftCPL(CPLsample(12),0); B=ans
% SGfigure; circshiftCPL(CPLsample(12),+1); B=ans
% SGfigure; circshiftCPL(CPLsample(12),+1); B=ans
% Gfigure; circshiftCPL(B,+1,true); B=ans
%
% See also: CPLcircshift
%
%
% Copyright 2017-2021 Tim C. Lueth

CPLcorrelate(CPLA,CPLB,corall)- correlates the contours from two CPLs

CPLcorrelate(CPLA,CPLB,corall)% CPLcorrelate(CPLA,CPLB,corall) - correlates the contours from two CPLs
% (by Tim Lueth, VLFL-Lib, 2017-JUN-04 as class: CLOSED POLYGON LISTS)
%
% In contrast to PLcorrelate, which correlates points for a single pair
% of a single contour, this fnctn here correlates contours to prepare the
% use of PLcorrelate. The correlation List contains in each row the
% corresponding contours of A and B, the level of the contour (0=most
% outside) and the parent contour of Ai and the parent contour of Bi
% The parameter list contains:
% the row number, the parent, the level and the center point [x y]
% (Status of: 2020-08-18)
%
% Introduced first in SolidGeometry 3.9
%
% See also: FLofPLcorrelation, SGconnect2FS, PLcorrelate, textCVL,
% PLtransform
%
% [CLL,NCA,NCB,a,b]=CPLcorrelate(CPLA,CPLB,[corall])
% === INPUT PARAMETERS ===
% CPLA: Contour A
% CPLB: Contour B
% corall: if true all contour are paired; default is false
% === OUTPUT RESULTS ======
% CLL: Correlation list [ACi BCi Level PAi PBi]
% NCA: Contours of A not existing in contour B
% NCB: Contours of B not existing in contour A
% a: complete list of used parameter of a [row parent level cx cy]
% b: complete list of used parameter of b [row parent level cx cy]
%
% EXAMPLE:
% CPLcorrelate(CPLsample(26),CPLsample(27)) % find exclusive pairs
% CPLcorrelate(CPLsample(27),CPLsample(26)) % find exclusive pairs
% CPLcorrelate(CPLsample(27),CPLsample(26),true) % pair all contours
%
% See also: FLofPLcorrelation, SGconnect2FS, PLcorrelate, textCVL,
% PLtransform
%
%
% Copyright 2017-2020 Tim C. Lueth

modN(n,k,N)- returns mod function for elements N:N+k(-1)

modN(n,k,N)% modN(n,k,N) - returns mod fnctn for elements N:N+k(-1)
% (by Tim Lueth, VLFL-Lib, 2017-JUN-04 as class: AUXILIARY PROCEDURES)
%
% auxiliary fnctn for array manipulation. Instead of return values
% between [0..k-1], this fnctn returns [N..N+k-1] by a=mod(n-N,k)+N
% (Status of: 2017-06-04)
%
% See also: mod1, mod
%
% a=modN(n,k,[N])
% === INPUT PARAMETERS ===
% n: number
% k: divider
% N: Interval start
% === OUTPUT RESULTS ======
% a: rest
%
% EXAMPLE:
% modN(1:6,3)
% modN(1:6,3,2)
%

FLofPLcorrelation(CL,nA,VL)- returns a facet list for a given point correspondance list

FLofPLcorrelation(CL,nA,VL)% FLofPLcorrelation(CL,nA,VL) - returns a facet list for a given point correspondance list
% (by Tim Lueth, VLFL-Lib, 2017-JUN-02 as class: SURFACES)
%
% Introduced first in SolidGeometry 3.9
%
% See also: PLcorrelate, CPLcorrelate, SGconnect2FS, PLtransform,
% SGof2CPLz, CLofFLW
%
% FL=FLofPLcorrelation(CL,[nA,VL])
% === INPUT PARAMETERS ===
% CL: Correspondance list
% nA: number of A points within VL; default is max(CL(:,1)
% VL: optional vertex list for a drawing
% === OUTPUT RESULTS ======
% FL: Facet list created by the correspondance list
%
% EXAMPLE:
% [CL,VL]=PLcorrelate(CPLsample(3),PLcircle(10,4));
% FLofPLcorrelation(CL,'',VL);
%
% See also: PLcorrelate, CPLcorrelate, SGconnect2FS, PLtransform,
% SGof2CPLz, CLofFLW
%
%
% Copyright 2017-2021 Tim C. Lueth

CPLconvexseg(CPL)- returns the segments of convex and concave contours a CPL.

CPLconvexseg(CPL)% CPLconvexseg(CPL) - returns the segments of convex and concave contours a CPL.
% (by Tim Lueth, VLFL-Lib, 2017-JUN-01 as class: ANALYTICAL GEOMETRY)
%
% ATTENTION. Convex and concave are related to ccw orientation
% +1 = convex (for ccw) [= concave for cw]
% -1 = concave (for ccw) [= convex for cw]
% Same fnctn as PLconvexseg for NAN separated CPLs (Status of: 2020-09-15)
%
% Introduced first in SolidGeometry 3.9
%
% See also: isconvexPL, PLconvexseg, CPLdecompose, PLdecompose
%
% con=CPLconvexseg(CPL)
% === INPUT PARAMETERS ===
% CPL: Single Point List
% === OUTPUT RESULTS ======
% con: array of convex and concave
%
% EXAMPLE:
% CPLconvexseg(PLcircle(10,6))
% CPLconvexseg(flipud(PLcircle(10,6)))
% CPLconvexseg(PLsample(9))
% CPLconvexseg(CPLsample(3))
%
% See also: isconvexPL, PLconvexseg, CPLdecompose, PLdecompose
%
%
% Copyright 2017-2020 Tim C. Lueth

PLconvexseg(PL)- returns the segments of convex and concave conoturs within ONE CPL

PLconvexseg(PL)% PLconvexseg(PL) - returns the segments of convex and concave conoturs within ONE CPL
% (by Tim Lueth, VLFL-Lib, 2017-JUN-01 as class: ANALYTICAL GEOMETRY)
%
% ATTENTION. Convex and concave are related to ccw orientation
% +1 = convex (for ccw) [= concave for cw]
% -1 = concave (for ccw) [= convex for cw]
% Same fnctn as CPLconvexseg for single PL (Status of: 2020-09-15)
%
% Introduced first in SolidGeometry 3.9
%
% See also: isconvexPL, CPLconvexseg, CPLisccwcorrected, CPLdecompose,
% PLdecompose
%
% [con,AL,CIL]=PLconvexseg(PL)
% === INPUT PARAMETERS ===
% PL: Single Point List
% === OUTPUT RESULTS ======
% con: array of convex and concave
% AL: Angle List
% CIL: Change index list plus status [n x 3]
%
% EXAMPLE:
% PLconvexseg(CPLsample(3));
% PLconvexseg(PLsample(9));
% PLconvexseg(CPLisccwcorrected(PLsample(9)));
%
% See also: isconvexPL, CPLconvexseg, CPLisccwcorrected, CPLdecompose,
% PLdecompose
%
%
% Copyright 2017-2020 Tim C. Lueth

replacemat(A,valold,valnew)- replaces values in vectors and matrices

replacemat(A,valold,valnew)% replacemat(A,valold,valnew) - replaces values in vectors and matrices
% (by Tim Lueth, VLFL-Lib, 2017-JUN-01 as class: AUXILIARY PROCEDURES)
%
% mainly: A(A==valold(i))=valnew(i)
% tab(mat) (Status of: 2017-06-01)
%
% replacemat(A,valold,valnew)
% === INPUT PARAMETERS ===
% A: vectors or matrices
% valold: existing values
% valnew: new values
%
% EXAMPLE:
% A=[1 2 3; 4 5 6], replacemat(A,1,9)
% A=[1 2 3; 4 5 6], replacemat(A,[1 9],[9 0])
%

distofintervall(a,b,inter)- distance within an intervall

distofintervall(a,b,inter)% distofintervall(a,b,inter) - distance within an intervall
% (by Tim Lueth, VLFL-Lib, 2017-MAI-31 as class: AUXILIARY PROCEDURES)
%
% maps a value in circular intervall (Status of: 2017-05-31)
%
% See also: norm
%
% [d,iv]=distofintervall(a,b,[inter])
% === INPUT PARAMETERS ===
% a: value 1
% b: value 2
% inter: intervall; default is [-pi +pi]
% === OUTPUT RESULTS ======
% d: distance ()
% iv: value a in intervall
%
% EXAMPLE:
% a=distofintervall (-pi+pi/10,pi-pi/10)
% a=distofintervall (1:10,2:11)
%

PLminangle(PL,in0,C,at)- returns the point with minimal angle value wrt to the center of the contour

PLminangle(PL,in0,C,at)% PLminangle(PL,in0,C,at) - returns the point with minimal angle value wrt to the center of the contour
% (by Tim Lueth, VLFL-Lib, 2017-MAI-31 as class: AUXILIARY PROCEDURES)
%
% Introduced first in SolidGeometry 3.9
%
% See also: PLminyx, PLminxy
%
% [P,pin,AL,DL,C]=PLminangle(PL,[in0,C,at])
% === INPUT PARAMETERS ===
% PL: Point Liste
% in0: false=[-pi..+pi]; true=[0..2*pi]; default is false
% C: optional center point
% at: angle threshold; default is pi/100
% === OUTPUT RESULTS ======
% P: Point with minimal y and minimal x
% pin: find index in PL
% AL: Angle list
% DL: Distance from Center List
% C: Center Point
%
% EXAMPLE:
% PLminangle(CPLspiral(10,20,8*pi))
% PLminabgle(CPLspiral(10,20,8*pi),true)
% PLminangle(CPLspiral(10,20,8*pi),true,[0 0])
% [~,ci]=PLminyx(CPLB); CPLB=circshift(CPLB,-(ci-1));
%
% See also: PLminyx, PLminxy
%
%
% Copyright 2017-2020 Tim C. Lueth

PLcorrelate(PLA,PLB,stype,ctype,mtype)- returns the correlation of two single point lists

PLcorrelate(PLA,PLB,stype,ctype,mtype)% PLcorrelate(PLA,PLB,stype,ctype,mtype) - returns the correlation of two single point lists
% (by Tim Lueth, VLFL-Lib, 2017-MAI-31 as class: CLOSED POLYGON LISTS)
%
% Auxiliary fnctn to correlate two point lists. It was designed first in
% SGof2CPLz.
% SGof2CPLz is still more powerful. (Status of: 2019-07-13)
%
% Introduced first in SolidGeometry 3.9
%
% See also: FLofPLcorrelation, SGconnect2FS, CPLcorrelate, PLtransform,
% SGof2CPLz
%
% [CL,VL]=PLcorrelate([PLA,PLB,stype,ctype,mtype])
% === INPUT PARAMETERS ===
% PLA: Point list A
% PLB: Point list B
% stype: 'number','length','angle','center','nearest', default 'center'
% ctype: 'org','minx','mina'/'rot'; default is 'mina'
% mtype: 'none', 'norm', 'norm1'
% === OUTPUT RESULTS ======
% CL: Correlation List
% VL: Vertex list [PLA;PLAB] without doubled points
%
% EXAMPLE:
% PLcorrelate(CPLsample(3),circshift(PLofCPL(CPLsample(3)),1))
% PLcorrelate(PLcircle(15),CPLsample(3))
%
% See also: FLofPLcorrelation, SGconnect2FS, CPLcorrelate, PLtransform,
% SGof2CPLz
%
%
% Copyright 2017-2021 Tim C. Lueth

SGofCPLzchamfer(CPL,z,ph,ed);- returns a solid with chamfered edges

SGofCPLzchamfer(CPL,z,ph,ed);% SGofCPLzchamfer(CPL,z,ph,ed); - returns a solid with chamfered edges
% (by Tim Lueth, VLFL-Lib, 2017-MAI-30 as class: SURFACES)
%
% Based on a comment of Florian Schleich. The body is divided into three
% planes. In order to ensure the calculation of the walls, the
% orientations of the contour are first adapted.
% In SG-Lib 5.0 separated regions are supported such as CPLsample(12)
% (Status of: 2021-02-23)
%
% Introduced first in SolidGeometry 3.9
%
% See also: SGofCPLz, SGof2CPLsz
%
% SG=SGofCPLzchamfer([CPL,z,ph,ed]);
% === INPUT PARAMETERS ===
% CPL: Closed Polygon line
% z: Height z
% ph: phase default is 0.3
% ed: curved edges; default is true
% === OUTPUT RESULTS ======
% SG: Resulting solid
%
% EXAMPLE:
% SGofCPLchamfer([CPLsample(21);NaN NaN;PLcircle(5)],10)
% SGofCPLzchamfer(CPLsample(12),10)
%
% See also: SGofCPLz, SGof2CPLsz
%
%
% Copyright 2017-2021 Tim C. Lueth

CPLisccwcorrected(CPL)- returns a CPL with all CPLs in correct orientation cw/ccw

CPLisccwcorrected(CPL)% CPLisccwcorrected(CPL) - returns a CPL with all CPLs in correct orientation cw/ccw
% (by Tim Lueth, VLFL-Lib, 2017-MAI-27 as class: CLOSED POLYGON LISTS)
%
% Slow fnctn - CPLisccwcorrectedCPS does the same (5.1) without cio return
% (Status of: 2020-01-02)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CPLisccwinout, CPLsortinout, CPLisccw, CPLsetallcw,
% CPLisccwcorrectedCPS
%
% [CPL,cio]=CPLisccwcorrected([CPL])
% === INPUT PARAMETERS ===
% CPL: Original CPL
% === OUTPUT RESULTS ======
% CPL: Corrected CPL
% cio: inside outside index
%
% See also: CPLisccwinout, CPLsortinout, CPLisccw, CPLsetallcw,
% CPLisccwcorrectedCPS
%
%
% Copyright 2017-2021 Tim C. Lueth

CPLisccwinout(CPL)- returns which contour has the right orientation wrt shell and orientation

CPLisccwinout(CPL)% CPLisccwinout(CPL) - returns which contour has the right orientation wrt shell and orientation
% (by Tim Lueth, VLFL-Lib, 2017-MAI-27 as class: CLOSED POLYGON LISTS)
%
% Depending on the outwards level, the orientation of a contour is:
% 0 = outward = ccw
% 1 = inward = cw
% 2 = outward = ccw
% 3 .....
% if length(corr)==sum(corr); the contour is correct (Status of:
% 2019-07-05)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CPLisccw, CPLsortinout, CPLisccwcorrected, CPLsetallcw
%
% [corr,cio,ccw]=CPLisccwinout(CPL)
% === INPUT PARAMETERS ===
% CPL: Contour polygon list
% === OUTPUT RESULTS ======
% corr: true if correct
% cio: level of contour (0=most outwards)
% ccw: ccw direction
%
% EXAMPLE:
% FCPL=replaceNaN(CPLsample(12),3,flipud(separateNaN(CPLsample(12),3)));
% CPLisccwinout(FCPL)
% CPLisccwinout(CPLsample(13))
%
% See also: CPLisccw, CPLsortinout, CPLisccwcorrected, CPLsetallcw
%
%
% Copyright 2017-2019 Tim C. Lueth

replaceNaN(CPL,ci,CPLi)- replaces or removes/ deletes a contour within a CPL

replaceNaN(CPL,ci,CPLi)% replaceNaN(CPL,ci,CPLi) - replaces or removes/ deletes a contour within a CPL
% (by Tim Lueth, VLFL-Lib, 2017-MAI-27 as class: AUXILIARY PROCEDURES)
%
% In SG-Lib 5.0 deleting a contour is possible (Status of: 2019-07-08)
%
% Introduced first in SolidGeometry 3.9
%
% See also: selectNaN, lengthNaN, cellofNaN, separateNaN, uniqueNaN,
% unsortNaN
%
% CPL=replaceNaN(CPL,ci,[CPLi])
% === INPUT PARAMETERS ===
% CPL: CPL
% ci: index of contour
% CPLi: new contour for contour ci
% === OUTPUT RESULTS ======
% CPL: Resulting CPL
%
% EXAMPLE:
% replaceNaN(CPLsample(12),3,flipud(separateNaN(CPLsample(12),3)));
% replaceNaN(CPLsample(12),3,'');
%
% See also: selectNaN, lengthNaN, cellofNaN, separateNaN, uniqueNaN,
% unsortNaN
%
%
% Copyright 2017-2020 Tim C. Lueth

CVLseparatez(CVL,z,thr)- returns a sliced CVL/CPL for a given z value

CVLseparatez(CVL,z,thr)% CVLseparatez(CVL,z,thr) - returns a sliced CVL/CPL for a given z value
% (by Tim Lueth, VLFL-Lib, 2017-MAI-26 as class: CLOSED POLYGON LISTS)
%
% for sliced CVL, i.e. CPL with an added z value, this fnctn returns only
% the contours that have the same z value (Status of: 2020-08-14)
%
% Introduced first in SolidGeometry 3.9
%
% See also: CVLofSGslices, SGofCVLslices, CPLofSGsliceauto,
% CVLzofSGsliceauto
%
% [CVLz,zL]=CVLseparatez(CVL,[z,thr])
% === INPUT PARAMETERS ===
% CVL: Slices CVL
% z: desired z value; currently only scalar
% thr: tolerance for finding a z value
% === OUTPUT RESULTS ======
% CVLz: Contours that fulfill the z-value condition; separated by NaN OR
% zl if isempty(z)
% zL: List of z Values
%
% EXAMPLE:
% CVL=CVLofSGslices(SGsample(5),10);
% CVLseparatez(CVL,3.3333333);
%
% See also: CVLofSGslices, SGofCVLslices, CPLofSGsliceauto,
% CVLzofSGsliceauto
%
%
% Copyright 2017-2020 Tim C. Lueth
RapidWeaver Icon

Last Change Oct 2023 for SG-Lib 5.3