While a few other functions already exist in FEX that compute the intersection points of curves, this short piece of code was written with speed being the highest priority. No loops are used throughout, taking full advantage of MATLAB's vectorization capabilitiesI welcome any comments, suggestions, bug reports etc.------------------------------------------------------------------------------INTERX Intersection of curves P = INTERX(L1,L2) returns the intersection points of two curves L1 and L2. The curves L1,L2 can be either closed or open and are described by two-row-matrices, where each row contains its x- and y- coordinates. The intersection of groups of curves (e.g. contour lines, multiply connected regions etc) can also be computed by separating them with a column of NaNs as for example L = [x11 x12 x13 ... NaN x21 x22 x23 ...; y11 y12 y13 ... NaN y21 y22 y23 ...] P has the same structure as L1 and L2, and its rows correspond to the x- and y- coordinates of the intersection points of L1 and L2. If no intersections are found, the returned P is empty. P = INTERX(L1) returns the self-intersection points of L1. To keep the code simple, the points at which the curve is tangent to itself are not included. P = INTERX(L1,L1) returns all the points of the curve together with any self-intersection points. Example: t = linspace(0,2*pi); r1 = sin(4*t)+2; x1 = r1.*cos(t); y1 = r1.*sin(t); r2 = sin(8*t)+2; x2 = r2.*cos(t); y2 = r2.*sin(t); P = InterX([x1;y1],[x2;y2]); plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')

This function computes the (x,y) locations where two curves intersect. The curves can be broken with NaNs or have vertical segments. It is also very fast (at least on data that represents what I think is a typical application).

Function calculates intersection of any two triangulated surfaces using triangle/triangle intersection algorithm proposed by Tomas Möller (1997) and implemented as highly vectorized MATLAB code. The algorithm was expanded to include calculation of the intersection surface, in addition to boolean matrix cataloging which triangle from one surface intersects with which triangle in the other surface. Function can be used for contour line calculations and can handle surfaces residing on the same plane.

A common request is to interpolate a set of points at fixed distances along some curve in space (2 or more dimensions.) The user typically has a set of points along a curve, some of which are closely spaced, others not so close, and they wish to create a new set which is uniformly spaced along the same curve.When the interpolation is assumed to be piecewise linear, this is easy. However, if the curve is to be a spline, perhaps interpolated as a function of chordal arclength between the points, this gets a bit more difficult. A nice trick is to formulate the problem in terms of differential equations that describe the path along the curve. Then the interpolation can be done using an ODE solver.As an example of use, I'll pick a random set of points around a circle in the plane, then generate a new set of points that are equally spaced in terms of arc length along the curve, so around the perimeter of the circle.theta = sort(rand(15,1))*2*pi;theta(end+1) = theta(1);px = cos(theta);py = sin(theta); 100 equally spaced points, using a spline interpolant.pt = interparc(100,px,py,'spline');% Plot the resultplot(px,py,'r*',pt(:,1),pt(:,2),'b-o')axis([-1.1 1.1 -1.1 1.1])axis equalgrid onxlabel Xylabel Ytitle 'Points in blue are uniform in arclength around the circle'You can now also return a function handle to evaluate the curve itself at any point. As well, CSAPE is an option for periodic (closed) curves, as long as it is available in your matlab installation.[~,~,foft] = interparc([],px,py,'spline');foft(0:0.25:1)ans = 0.98319 0.18257 -0.19064 0.98151 -0.98493 -0.17486 0.18634 -0.98406 0.98319 0.18257

This submission contains a set of files for analyzing N-dimensional convex polyhedra. It is intended for fairly low dimensions N -- basically low enough so that vertex and facet enumeration using MATLAB's convhulln() command is tractable. For now, it is also limited to bounded polyhedra (i.e., polytopes). A bounded convex polyhedron can be represented either as the convex hull of a finite set of vertices V(i,:) or by using a combination of linear constraint equalities and inequalities, A*x<=b, Aeq*x=beqHere, A and Aeq are MxN and PxN matrices while b and beq are Mx1 and Px1 column vectors, respectively. The (in)equality representation expresses the polyhedron as the intersection of two regions. One region is a solid N-dimensional shape, described by the inequalities, while the other is a possibly lower-dimensional sub-space, described by the equalities. The screenshot above illustrates this, showing how a triangle in 3D can be represented as the intersection of a tetrahedron (a solid shape in R^3) and a plane.The package contains tools for converting between the two representations (see VERT2LCON and LCON2VERT) as well as for taking intersections and unions of polyhedra in either form (see intersectionHull and unionHull).The package was inspired by Michael Kleder's vert2con and con2vert functions, which were limited to N-dimensional polyhedra possessing non-zero volume in R^N.Thus, for example, they could not handle a triangle floating in R^3 as depicted in the above screenshot. Although a triangle has non-zero volume (i.e., area) in R^2 it has zero volume in R^3. The extension made in this package covers general bounded polyhedra. NOTE: however, when using linear constraint data A, b, Aeq, beq to represent a given polyhedron, it is important that the inequalities A*x<=b still be chosen to correspond with a region of non-zero N-dimensional volume. Zero-volume polyhedra are captured by adding equality constraints Aeq*x=beq. EXAMPLE: Consider the 3D polyhedron defined by x+y+z=1, x>=0, y>=0, z>=0. Equivalent constraint in/equalities can be obtained from the known vertices by doing, >> [A,b,Aeq,beq]=vert2lcon(eye(3)) A = 0.4082 -0.8165 0.4082 0.4082 0.4082 -0.8165 -0.8165 0.4082 0.4082 b = 0.4082 0.4082 0.4082 Aeq = 0.5774 0.5774 0.5774 beq = 0.5774Conversely, the vertices can be obtained by doing, >> V=lcon2vert(A,b,Aeq,beq) V = 1.0000 0.0000 0.0000 0.0000 0.0000 1.0000 -0.0000 1.0000 0.0000When an interior point of the polyhedron is known a priori, one can instead use QLCON2VERT, a quicker version of LCON2VERT which uses the known point to get around some computationally intensive steps.

This function computes the locations where a curve self-intersects in a fast and robust way. The curve can be broken with NaNs or have vertical segments. Segments of the curve involved in each of the self-interesections are also provided.Example of use:N=201;th=linspace(-3*pi,4*pi,N);R=1;x=R*cos(th)+linspace(0,6,N);y=R*sin(th)+linspace(0,1,N);t0=clock;[x0,y0,segments]=selfintersect(x,y)etime(clock,t0)plot(x,y,'b',x0,y0,'.r');axis ('equal'); grid

I've seen many people ask for a way to find the closest point on a curve from some given point in space. If the curve is a piecewise linear one, this is not too difficult, since this reduces to finding the closest point on a line segment, and then testing each line segment. (With care, you need not test EVERY line segment.)For a cubic spline however, this becomes more difficult, but still doable in a mathematical sense without an explicit optimization. Not too much more than roots is necessary.Distance2curve allows you to specify a set of general points in an n-dimensional space as a connected space curve. A spline (or pchip) is then fit in terms of arc length along the curve, and the closest point identified.

Function circumcenter finds the radius R and the center of the circumscribed circle of a triangle in 3D space. Function curvature calls circumcenter for every triplet , , of neighboring points along the curve. The curvature is defined as . The curvature vector is , where is the unit vector in the direction from to the center of the circle.Note that this local calculation is sensitive to noise in the data.The syntax is:[L,R,K] = curvature(X)X: array of column vectors for the curve coordinates. X may have two or three columns.L: Arc lengthR: Curvature radiusK: Curvature vector

GeneralThis file is based on the Curve Intersect function by Duane Hanselman. It extends the scope of the function to handle arbitrary lines / polygons, which may also have vertical segments or segments with non-increasing x-values.DescriptionCalculate the intersection points of two 2D-lines / polygons.Usage[X,Y]=CURVEINTERSECT(H1,H2) or [X,Y]=CURVEINTERSECT([H1 H2]) or[X,Y]=CURVEINTERSECT(X1,Y1,X2,Y2) or -> (H1,H2) handles to line objects -> (Xi,Yi) coordinates of lines -> (X,Y) coordinates of intersectionExamplex1=rand(10,1); y1=rand(10,1); x2=rand(10,1); y2=rand(10,1);[x,y]=curveintersect(x1,y1,x2,y2); plot(x1,y1,'k',x2,y2,'b',x,y,'ro')

The command linexlines2D() offered in this submission is a flexible tool for computing the intersection points between a reference 2D line segment and a batch of other 2D line segments. Either the reference line segment or those in the batch (or both) can also be infinite lines, specified by 2D line equations.If a batch of line segments is given, they may form an arbitrary cloud of line segments or they may form the boundaries of a polyshape. If the latter, the batch can be specified by passing a polyshape object as input to linexlines2D(). The thumbnail image above illustrates an example of this. Additional illustrations of usage can be found under the Examples tab.

%plane_line_intersect computes the intersection of a plane and a segment (or a straight line)% Inputs: % n: normal vector of the Plane % V0: any point that belongs to the Plane % P0: end point 1 of the segment P0P1% P1: end point 2 of the segment P0P1%%Outputs:% I is the point of interection % Check is an indicator:% 0 => disjoint (no intersection)% 1 => the plane intersects P0P1 in the unique point I% 2 => the segment lies in the plane% 3=>the intersection lies outside the segment P0P1%% Example:% Determine the intersection of following the plane x+y+z+3=0 with the segment P0P1:% The plane is represented by the normal vector n=[1 1 1]% and an arbitrary point that lies on the plane, ex: V0=[1 1 -5]% The segment is represented by the following two points% P0=[-5 1 -1]%P1=[1 2 3] % [I,check]=plane_line_intersect([1 1 1],[1 1 -5],[-5 1 -1],[1 2 3]);

Ray/triangle intersection using the algorithm proposed by Möller and Trumbore (1997), implemented as highly vectorized MATLAB code. The algorithm can work with one and two sided surfaces, as well as, withinfinite lines, rays (lines bounded on one side) and segments (lines bounded on both sides). Input (all arrays in in Nx3, where N is number of vertices or rays): orig : ray's origin dir : ray's direction vert0, vert1, vert2: vertices of the triangle Output: Intersect - boolean array of length N t - distance from the ray origin to the intersection point in |dir| u,v - barycentric coordinates of the intersection point units xcoor - carthesian coordinates of the intersection pointIn addition PointInsideVolume is 3D equivalent to 2D inpolygon function and can test ifarray of points is inside or outside any volume defined by the surface grid.

Fill Between Area Curve Version 1.0DescriptionThe Fill Between Area Curve creates a shaded area between two data series, effectively highlighting the region of overlap or difference.DependenciesFor optimal performance and accurate graphs, please install the Mapping Toolbox .SyntaxfillBetweenAreaCurve(x, y1, y2) shades the area between 2 lines formed by y1 and y2fillBetweenAreaCurve(x, y1, y2, c) shades the area between 2 lines formed by y1 and y2 with color c.fillBetweenAreaCurve(__, Name, Value) specifies additional options for the FillBetweenAreaCurve using one or more name-value pair arguments. Specify the options after all other input arguments.Name-Value Pair Arguments/PropertiesXData Array containing values of x-coordinates for both plots y1 and y2. Note: x-coordinates for both y1 and y2 should be common Y1Data y-coordinates of y1 plotY2Data y-coordinates of y2 plotCondition The condition property selectively shades the area based on the condition provided by the user.ShadeInverse Shades all the unshaded regions between 2 curves with a different color.OptimizePerformance Calculate the vertices of triangles that compose the patch manually instead of asking patch to do itStylistic Name-Value Pair Arguments/PropertiesFaceAlpha Describes opacity of shaded area. If set to 1, the shaded area is completely opaque. If set to 0, the shaded area is completely transparent.FaceColor Describes the color of shaded area specified by ConditionInverseFaceColor If ShadeInverse is set to true, we shade the unshaded region with InverseFaceColorLine1Color Line color for plot describing y1 valuesLine2Color Line color for plot describing y2 valuesXLabel Label for x axisYLabel Label for y axisLine1LineStyle Line Spec for plot describing y1 valuesLine2LineStyle Line Spec for plot describing y2 valuesLine1LineWidth Line Width for plot describing y1 valuesLine2LineWidth Line Width for plot describing y2 valuesLabel1 Label for plot describing y1 valuesLabel2 Label for plot describing y2 valuesTitle Title of the chartHow to use% Intialize some data x = linspace(0, 4 * pi, 20);y_sinx = sin(x);y_cosx = cos(x);% Create a basic FillBetweenAreaCurveareaCurve = fillBetweenAreaCurve(x, y_sinx, y_cosx);% Create a basic FillBetweenAreaCurve with magneta shadingareaCurveMagneta = fillBetweenAreaCurve(x, y_sinx, y_cosx, 'm');% Create a FillBetweenAreaCurve with selective shadingareaCurveSelectiveShading = fillBetweenAreaCurve(x, y_sinx, y_cosx, 'Condition', @(x, y1, y2) x > 2 & x < 4);areaCurveCondition2.ShadeInverse = false;

This routine will shade the area of a 2-D plot between two user defined vectors. Simply pass the two vectors, and their corresponding horizontal coordinates, select your fill color and transparency level and viola! You have a figure that is colored in between the two input vectors.

easy to use for any type of line and curve intersection with example.

% Inputs: % N1: normal vector to Plane 1% A1: any point that belongs to Plane 1% N2: normal vector to Plane 2% A2: any point that belongs to Plane 2%Outputs:% P is a point that lies on the interection straight line.% N is the direction vector of the straight line% check is an integer (0:Plane 1 and Plane 2 are parallel' % 1:Plane 1 and Plane 2 coincide% 2:Plane 1 and Plane 2 intersect)% Example:% Determine the intersection of these two planes:% 2x - 5y + 3z = 12 and 3x + 4y - 3z = 6% The first plane is represented by the normal vector N1=[2 -5 3]% and any arbitrary point that lies on the plane, ex: A1=[0 0 4]% The second plane is represented by the normal vector N2=[3 4 -3]% and any arbitrary point that lies on the plane, ex: A2=[0 0 -2]% [P,N,check]=plane_intersect([2 -5 3],[0 0 4],[3 4 -3],[0 0 -2]);

OUT = LINESEGMENTINTERSECT(XY1,XY2) generates intersection analysis between the line segment sets given in XY1 and XY2. Code can handle coincident and parallel lines.The main emphasis is on speed. The code is fully vectorized and it runs pretty fast (orders of magnitude) compared to some of the previous postings.

MINTERSECT(A,B,C,...) when A,B,C... are vectors returns the values common to all A,B,C... The result will be sorted. A,B,C... can be cell arrays of strings. MINTERSECT repeatedly evaluates INTERSECT on successive pairs of sets, which may not be very efficient. For a large number of sets, this should probably be reimplemented using some kind of tree algorithm.MINTERSECT(A,B,'rows') when A,B,C... are matrices with the same number of columns returns the rows common to all A,B,C...

[sigma,mu,A]=mygaussfit(x,y)[sigma,mu,A]=mygaussfit(x,y,h)this function is doing fit to the functiony=A * exp( -(x-mu)^2 / (2*sigma^2) )the fitting is been done by a polyfitthe lan of the data.h is the threshold which is the fractionfrom the maximum y height that the datais been taken from.h should be a number between 0-1.if h have not been taken it is set to be 0.2as default.

% Putative points of intersection between each pair of surfaces are located% by assuming that each constituent mesh triangle edge represents an% infinitesimal ray, then solving the ray-triangle intersection problem % using the Barycentric coordinate based solution presented by Möller and % Trumbore [1997: vectorized implementation for speed]. Positive % intersections occur when the intersecting point, p0 lies between the end % nodes of its corresponding triangle edge (p1, p2), identified when the % following criterion is satisfied:% ‖p0 - p1‖ + ‖p0 - p2‖ = ‖p1 - p2‖% Note: rounding errors do not permit solving of the above criteria % directly. Dot and cross functions are instead used for constraining% whether the point is between the triangle edge end nodes.% Ray tracing becomes prohibitive for meshes greater than a few thousand % triangles. The reliance on spatial partitioning using octree subdivision% carries overhead in binning the two input meshes, but is still usually% MUCH faster than a brute force search for most mesh objects.% INPUT:% pointsA: nx3 vertex list for mesh A% pointsB: nx3 vertex list for mesh B% facesA: nx3 face list of triangle corner indices for mesh A% facesB: nx3 face list of triangle corner indices for mesh B% octs: maximum bin size (single integer)% OUTPUT% intersections: nx3 vertex list of intersections between the two meshes% Note: the octree object is created using the excellent octree.m function of Sven:% http://www.mathworks.com/matlabcentral/fileexchange/40732-octree-partitioning-3d-points-into-spatial- % subvolumes% Test data (testData.mat) containing two meshed intersecting fractal surfaces is provided with the package

Simple program to generate the inner and outer parallel curves in rectangular coordinates. inner parallel is toward the center of curvature and outer parallel is away from the center of curvature. Use option flag1=0 to keep the parallels on the side sides (disregarding concavity). The Input the x, y coordinate pairs and distance between the curve and the parallels and the option to make a plot. Parallel curves are related to the involute, evolute, and envelope. Program can easily be modified to generate the evolute by replacing d with R in lines 254-270.

See file header

The arclength function computes the length of a general space curve. This is not too difficult if the curve is assumed to be piecewise linear (a one liner) but if the curve is to be a smoothly interpolated spline, then the problem becomes more difficult.A nice way to solve this problem for the cubic case is to formulate it as a numerical integration, whereupon the solution can be gained from quadgk. Carefully written code breaks the problem into a series of integrals between each pair of breaks on the curve to avoid the derivative singularities one would find otherwise.

This recursive function calculates coordinates of n-th order Hilbert curve. It is then possible to plot it using the "line" command.

Presenting the one and only Generalised Bezier curve !!!! Yes folks Matlab code for n points , this program will plot the Bezier curve for any number of points be it 2 or 3 or even 100 or more points ...1)First enter the no. of points when the program asks 2)Choose whether you prefer to click or to enter through keyboard in the form of matrix all the x & y coordinates 3)Click on various locations in the window or enter through keyboard the coordinates of all points must be within square brackets for example for 4 points whose (1,2),(4,6),(7,8),(10,11) enter like this [1 2;4 6;7 8;10 11] 5)Sit back and enjoy !6)The line segments joining the control points are also plotted NOTE : If the program doesnt work try to rate it 5 stars then try it it will WORK ;)

Examples of Three dimensional curves described in Chapter 7 ofthe book: "CRC Standard Curves and Surfaces" by David von Seggern (1993).The zip file includes the following curves:a) Helical curves: - Circular helix (right helicoid). - Elliptical helix. - Conical helix. - Spherical helix. - n-Helix.b) Sine waves in three dimensions - Sine wave on Cylinder. - Sine wave on Sphere. - Sine wave on Hyperboloid of one sheet. - Sine wave on Cone. - Rotating sine wave.c) Miscellaneous spirals - SiCi spiral - Toroidal spiral - Intersection of Sphere and Cylinder

Purpose: Range/interval intersectionA and B two ranges of closed intervals written as vectors [lowerbound1 upperbound1 lowerbound2 upperbound2] or as matrix [lowerbound1, lowerbound2, lowerboundn; upperbound1, upperbound2, upperboundn]A and B have to be sorted in ascending orderout is the mathematical intersection A n BEXAMPLE USAGE: >> out=range_intersection([1 3 5 9],[2 9]) out = [2 3 5 9] >> out=range_intersection([40 44 55 58], [42 49 50 52]) out = [42 44]

The function is used to calculate Isc and Voc in addition to plotting the characteristic IV curve.The functions takes the cell's parameters as inputs. The performance of the solar cell and its characteristic curves are determined by the cell's parameters.These Parameters are:- short circuit current density(J_sc), reverse saturation current density (J_o), Area (A), and ideality factor(If), Temparature in kelvin (T), Irradiance (G),series resistance(R_s) and shunt resistance(R_sh).An example;J_sc=34.3*10^-3;J_o=10*10^-10;A=pi*(3*2.5)^2;G=[1000,800,600];R_sh=100;R_s=0;T=298; If=1.5;Plot_IV(J_sc,J_o,A,T,If,G,R_sh,R_s)

This is a simple program that constructs a Bezier curve using a given number of control points. Besides, it also plots the corresponding characteristic polygon.

Application for generating the Koch curve (or Koch snowflake) fractal by selecting the number of iterations. Just unzip and run the Koch_curve_GUI.m file.

Please first check the examples tab (.mlx file) here on the right for a complete description.Once downloaded, typewrite 'help planes_intersection' or 'doc planes_intersection' in Matlab console for support.To benefit from the file documentation attached, be sure to download the file, not to just copy and paste it.Please don't forget to rate it if this code helped you. Thanks ! ;-)

A MATLAB version of Dubins Curve based on Andrew Walker's workA Dubin's curve is a nearly kinemetically feasible path solution for car-like platform. The method explicitly find the trajectory composed of 3 segment: two curves and one staight line, or three curves. The curves are part of the circle. There are only 6 kind of the composition that proved to be minimun in length, and thease 6 types are called Dubin's curve. In the program, the shourtest path is found and taken as the desired path. Despite the kindly source code that Andrew Walker has provided, I'm still tired of searching the method to implement the C++ code into MATLAB using MEX and other compiler. Thus I decided to write my own MATLAB .m file.

In material science curved surfaces may be heated due to study thermal flow.Here a simple image is projected on top of the peaks surface and the red are is measured in square pixels. Deaunay is used to create triangles whos area is summed up, if the color criteria is met.

xsol=fzero_data(x,y,y0);"fzero.m" function (Optim toolbox) computes one zero of a defined one-variable function, while "fzero_data.m" computes all the zeros (or crossings) of data vectors x and y at y=y0. The number of solutions can be found with "length(xsol)". If the requested value y=y0 is not in the range of the data, an error will stop the program. For better accuracy the function "spline()" instead of "interp1()" can be inserted in the last loop of the function.%%%%%%%%%% example %%%%%%%%%theta=0:0.01:2*pi;f=sin(2.*theta);%find the solutions for f=0f0=0;theta0=fzero_data(theta,f,f0);Nsol0=length(theta0);%find the solutions for f=0.95f1=0.95;theta1=fzero_data(theta,f,f1);Nsol1=length(theta1);plot(theta,f,'-k',[0,theta0],f0.*ones(1,Nsol0+1),'-*r',[0,theta1],f1.*ones(1,Nsol1+1),'-ob')%%%%%%%%%%%%%%%%%%%%%%%%%%

POLYPREDCI takes the actual (x,y) data and polynomial order as arguments, uses ‘polyfit’ and ‘polyval’ to do the regression, then calculates and returns the fitted curve and the one-sided prediction confidence intervals on the fit. It uses the one-tailed t-statistic to calculate the confidence intervals. That calculation is entirely contained within POLYPREDCI, so the Statistics and Machine Learning Toolbox is not required. (It does not calculate confidence intervals for the parameters. See the related function ‘polyparci’ for that.) It is extensively internally documented. POLYPREDCI follows published equations (in several references) to calculate the confidence intervals. They are close to but not the same as those calculated by ‘nlpredci’. I have no idea how ‘nlpredci’ calculates its confidence intervals, since they do not appear in the documentation that I can find. POLYPREDCI has three required arguments and two optional arguments. The three required arguments are: ‘x’ (the independent data vector), ‘y’ (the dependent data vector), and ‘n’ (the polynomial order). The two optional arguments are ‘alfa’ (the desired level of statistical significance), and ‘xv’ (high-resolution vector for polynomial fit and confidence interval calculations). The default value for ‘alfa’ is 0.95. POLYPREDCI was stimulated by a Question from ‘pocketHands’ on 2016 06 10, who thought ‘polyparci’ would do this. (It won’t!) POLYPREDCI was created with R2016a but should work on all recent releases. Example on using POLYPREDCI: x = linspace(0, 2.5, 15); % Create Datay = 2 + 3*x.^2 + 5*randn(size(x)); % Create Datan = 3; % Polynomial Orderalfa = 0.99; % Desired Significance xv = linspace(min(x), max(x))'; % Optional High-Resolution Vector[ p, yhat, ci ] = polypredci( x, y, n, alfa, xv ); % Define Both ‘alfa’ & ‘xv’% [ p, yhat, ci ] = polypredci( x, y, n, alfa ); % Use ‘alfa’% [ p, yhat, ci ] = polypredci( x, y, n ); % Use Defaultsfigure(1)plot(x, y, 'bp')hold onif length(yhat) == length(x) plot(x, yhat, '--r') plot(x, yhat+ci, '--g') plot(x, yhat-ci, '--g')elseif length(yhat) == length(xv) plot(xv, yhat, '--r') plot(xv, yhat+ci, '--g') plot(xv, yhat-ci, '--g')endhold offgrid

String art, or pin and thread art, is characterized by an arrangement of colored thread strung between points to form geometric patterns. Though straight lines are formed by the string, the slightly different angles and metric positions at which strings intersect gives the appearance of Bézier curves (as in the mathematical concept of envelope of a family of straight lines). Quadratic Bézier curve are obtained from strings based on two intersecting segments. String art has its origins in the 'curve stitch' activities invented by Mary Everest Boole at the end of the 19th century to make mathematical ideas more accessible to children. It was popularised as a decorative craft in the late 1960s through kits and books.Syntax: stringart(varargin)Properties: 'Sides' - sides number of polygon you want to use (default = 3) 'Crossed' - logical value that says if you want to use the perimeter (0 - default) or bisettrices of vertices (1). 'Density' - The number of pins you want to use for each side default = 40) 'Color' - 1x3 vector that indicates the colors of the wires (default = [0 0 0] black)Created by Giuseppe Cardillo giuseppe.cardillo-edta@poste.itTo cite this file, this would be an appropriate format: Cardillo G. (2018) Stringart: Play with geometry and Bézier's quadratic curve https://it.mathworks.com/matlabcentral/fileexchange/68252

Consider a binary classification task, and a real-valued predictor, where higher values denote more confidence that an instance is positive. By setting a fixed threshold on the output, we can trade-off recall (=true positive rate) versus false positive rate (resp. precision). Depending on the relative class frequencies, ROC and P/R curves can highlight different properties; for details, see e.g., Davis & Goadrich, 'The Relationship Between Precision-Recall and ROC Curves', ICML 2006.

Please first check the examples tab (.mlx file) here on the right for a complete description.Once downloaded, typewrite 'help line_plane_intersection' or 'doc line_plane_intersection' in Matlab console.To benefit from the file documentation attached, be sure to download the file, not to just copy and paste it.Please don't forget to rate this code if it helped you. Thanks ;-)

Calculate intersection point of two 2d lines specified with 2 points each(X1, Y1; X2, Y2; X3, Y3; X4, Y4), while 1&2 and 3&4 specify a line.Gives back NaN or Inf/-Inf if lines are parallel (= when denominator = 0)see http://en.wikipedia.org/wiki/Line-line_intersection

JOHNSON CURVE TOOLBOX FOR MATLABby David L. Jones, PhDJohnson (1949) developed a flexible system of distributions, based on three families of transformations, that translate an observed, non-normal variate to one conforming to the standard normal distribution. The exponential, logistic, and hyperbolic sine transformations are used to generate log-normal (SL), unbounded (SU), and bounded (SB) distributions, respectively. This allows a unique distribution to be derived for whatever combination of mean, standard deviation, skewness, and kurtosis occurs for a given set of observed data. Once a variate is appropriately transformed, probability densities and percentage points may be derived based on the standard normal curve.This TOOLBOX is a set of MATLAB functions for working with the Johnson system of distributions to analyze non-normal, univariate data sets. Portions of it are based on my MATLAB port of Hill et al.'s (1976) AS-99 and Hill's (1976) AS-100 FORTRAN-66 code.CONTENTS:f_johnson_M - use moments to estimate parameters of a Johnson distributionf_johnson_Q - use quantiles to estimate parameters of a Johnson distributionf_johnson_aic - calculate AIC, AICc, and BIC for a Johnson distributionf_johnson_cdf - cumulative probability density function for a Johnson distributionf_johnson_fit - fit a Johnson distribution to observed dataf_johnson_inv - inverse of the CDF for a Johnson distributionf_johnson_lik - negative log-likelihood for a Johnson distributionf_johnson_pdf - probability density function for a Johnson distributionf_johnson_rnd - generate random numbers from a Johnson distributionf_johnson_y2z - transform Johnson variates to standard normal variatesf_johnson_z2y - transform standard normal variates to Johnson variatesCITATION:Jones, D. L. 2014. The Johnson Curve Toolbox for Matlab: analysis of non-normal data using the Johnson system of distributions. College of Marine Science, University of South Florida, St. Petersburg, Florida, USA.NOTES:Some functions have detailed documentation and references that can be viewed in the Matlab editor. The 'examples' folder includes demonstrations of how to use the functions to fit biological, environmental, demographic, and financial data sets.REFERENCES:Hill, I. D. 1976. Algorithm AS 100: Normal-Johnson and Johnson-Normal Transformations. Journal of the Royal Statistical Society. Series C (Applied Statistics) 25(2): 190-192.Hill, I. D., R. Hill, and R. L. Holder, 1976. Algorithm AS 99: Fitting Johnson curves by moments. Journal of the Royal Statistical Society. Series C (Applied Statistics) 25(2): 180-189.Johnson, N. L. 1949. Systems of frequency curves generated by methods of translation. Biometrika 36: 180-189.

This function allows you to simultaneously fit multiple data sets (for example noisy measurements) with multiple models, which share some (or all) of the fitting parameters.Unlike difference approaches using fminsearch (or similar functions), this submission wraps around NLINFIT and thus allows immediate estimation of confidence intervals on data predictions and fitted parameters.

The Ezyfit toolbox for Matlab enables you to perform simple curve fitting of one-dimensional data using arbitrary (non linear) fitting functions.EzyFit adds a new menu to your figure windows, which allows you to easily fit your data with predefined or user-defined fit equations, including selection of your data (outliers removing) using the ``Data Brushing'' tool available since Matlab 7.6).This toolbox also provides a set of command-line functions to perform curve fitting 'programmatically': you just have to type something like showfit('c+a/x^n') and EzyFit gives you the values for c, a and n and shows you the curve!Visit http://www.fast.u-psud.fr/ezyfit/ for additional info.Installation and system requirementsEzyFit needs Matlab 7.0 or higher. It has been tested up to R2015b, but mainly under Windows. The command-line functions (e.g. ezfit, showfit...) work equally well on all systems. However graphical operations (e.g. showslope, getslope...) are not fully stable.1. Download and unzip the EzyFit Toolbox in a directory somewhere in your system. For instance, in a Windows installation, the directory Documents/MATLAB/ezyfit may be a good location. Do NOT install the toolbox in the Matlab directory itself (Program Files/Matlab directory in Windows). If you upgrade from an older version, first empty the previous directory.2. Select 'Set Path' (available in the menu File in Matlab 7, or in the tab Home in Matlab 8). In the dialog box, click on 'Add Folder' (NOT 'with subfolders') and select the ezyfit directory. Click on 'Save' and 'Close'.3. If you want to always have the Ezyfit menu in your figures, type'efmenu install'. This will create or update your 'startup.m' file.Note: If you upgrade Matlab and you want to use your previous Ezyfit installation, you just have to follow the steps 2-3.Examples:plotsample power % a power lawshowfit c*x^nplotsample hist % an histogramf = ezfit('gauss'); % fits with a Gaussianf % displays the values of the coefficients

ROC - Receiver Operating Characteristics.The ROC graphs are a useful technique for organizing classifiers and visualizing their performance. ROC graphs are commonly used in medical decision making.YOU CAN USE THIS FUNCTION ONLY AND ONLY IF YOU HAVE A BINARY CLASSIFICATOR.The input is a Nx2 matrix: in the first column you will put your test values (i.e. glucose blood level); in the second column you will put only 1 or 0 (i.e. 1 if the subject is diabetic; 0 if he/she is healthy).Run rocdemo to see an exampleThe function computes and plots the classical ROC curve and curves for Sensitivity, Specificity and Efficiency (see the screenshot).The function will show 6 cut-off points:1) Max sensitivity2) Max specificity3) Cost effective (Sensitivity=Specificity)4) Max Efficiency5) Max PLR6) Max NLRROC requires the Curve fitting toolbox.

% Ray-triangle intersection algorithm of Muller and Trumbore (1997)% formatted for arrayfun to allow hardware acceleration% Call with gpuarray and arrayfun to execute on the GPU: thjs% may give two orders of magnitude speed up over vectorized% cpu based implementation % INPUT: % P0x, P0y, P0z / P1x, P1y, P1z / P2x, P2y, P2z: xyz components of the% triangle objects% orx, ory, orz: xyz componants of the ray origin% Dx, Dy, Dz: xyz components of the ray directional (unit) vectors% OUTPUT:% distOut: distance from from the ray-tri intersection to the origin or nan % if no intersection is located% flag: logical where true indicates intersection and false indicates % no intersection% Usage example: % Step 1: convert mx3 direction vectors, D = [Dx Dy Dz] to gpuarray object% >> gD = gpuArray(D);% Step 2: call rayTriGPU using arrayfun with scalar input formatting% where P0, P1, P2 are the nx3 vertex lists of the triangle corner points% and where or is the xyz coordinates of the origin% >> [dist, flag] = arrayfun(@rayTriGPU, P0(:,1)', P0(:,2)', P0(:,3)', ...% P1(:,1)', P1(:,2)', P1(:,3)', ...% P2(:,1)', P2(:,2)', P2(:,3)', ...% or(:,1), or(:,2), or(:,3), ...% gD(:,1),gD(:,2),gD(:,3));% Step 3: recover data% distances = gather(dist);% Output is an mxn array containing a the distance from the ray-tri% intersection to the origin or nan if no intersection is located% Implentation based upon that of Paul Peeling (originally from Jesus P.% Mena-Chalco of FEX), MathWorks (which returns a flag but not the % intersection distance).% Per ray flags can be obtained from the output dist using the following % method:% >> flagT = true(size(D,1),1); % >> flagT(sum(isnan(dist),2) == size(P0,1)) = false;% This may save transfer time off the GPU% Dependencies: requires Parallel Computing Toolbox% Test data (testDataTri.mat) is provided with the package % references% Fast, Minimum Storage Ray/Triangle Intersection, Möller & Trumbore. % Journal of Graphics Tools, 1997.

Arbitrary ELIPSOID and A PLANE INTERSECTION function[Aye,Bye,qx,qy,qz]=intersection_elipsoid_plane2(elp,plane) % Plane equation AA.x + BB.y + CC.z+ DD = 0% Standart Ellipsoid equation (x/a)^2 + (y/b)^2 + (z/c)^2 = 1 % Arbitrary Ellipsoid equation Ax^2 + By^2 + Cz^2 +2 Dxy + 2Exz + 2Fyz + 2Gx + 2Hy + 2Iz + J = 0 % Author: Sebahattin Bektas,Ondokuz Mayis University,2015 %% Inputs -----------------------------------------------------------------% Plane=[AA BB CC DD] :Plane equation's coefficients 1x4% % for standard ellipsoid elp must be 1x3 =[a b c]% for arbitrary ellipsoid elp must be 1x10 =[ A B C D E F G H I J]%% elp=[a b c]: Semi-axes of standart ellipsoid % or% elp=[ A B C D E F G H I J]: Arbitrary Ellipsoid coefficient% Outputs ----------------------------------------------------------------% Aye: Semi-major axis of intersection ellipse% Bye: Semi-minor axis of intersection ellipse%% qx,qy,qz : Cartesian coordinates of intersection ellipse's center% This source code is given for free! However, I would be grateful if you refer % to corresponding article in any academic publication that uses % this code or part of it. % Please refer to: % BEKTAS, S Orthogonal distance from an ellipsoid. Bol. Ciênc. Geod. [online]. 2014, vol.20, n.4, pp. 970-983. ISSN 1982-2170. % BEKTAS, S Intersection of an Ellipsoid and a Plane,International Journal of Research in Engineering and Applied Sciences VOLUME 6,ISSUE 6,2016

This program allows you to analyze the size of grains in a micrograph with the intersection method arranged in a user-friendly GUI.After loading the micrograph the program puts lines on the surface. Now you have to use the cursor to click on the intercept of the lines with the grain boundaries. Concluding you get an editable and savable histogram and a txt-file containing the length of the grains.You can also analyze existing txt-files to get the histogram (including lognormal distribution fitting) or an empirical cumulative distribution function plot of different micrographs and you can compare them in one chart. In addition you get a lot of features (e.g. rotate image) and fully control about many settings.The GUI should be mostly self-explanatory, anyway I recommend this screencast, in which all features are explained.http://www.screencast.com/t/O9kWfH9Hwn Alternative on YouTube:as playlist: http://www.youtube.com/playlist?list=PL08596CB91051E91BPart 1 (Image): http://youtu.be/La-T07Ba_cg?hd=1Part 2 (File): http://youtu.be/BIsf-jgc2UY?hd=1Part 3 (CDF): http://youtu.be/VGuhAMuWgxQ?hd=1Part 4 (rotate image): http://youtu.be/hdHxUM63QaY?hd=1Part 5 (save settings): http://youtu.be/jHRAmRdyQA4?hd=1If you have special questions please check the header of the .m file and email the responsible person:matthias.funk@kit.edusven.meister@student.kit.edujochen.lohmiller@kit.eduThis submission based on the idea and code of Matthias Funk from the Karlsruhe Institute of Technology (KIT), IAM-WBM, Nachwuchsgruppe für microreliability. This project was financed by DFG-SFB499N01. The lognormal distribution fitting in histogram was created by Jochen Lohmiller based on: C.E. Kril, R. Birringer, Esimating grain-size distributions in nanocrystalline materials from X-ray diffraction profile analysis, Phil. Mag. A, 77: 3, 621 — 640

Finding intersection point of lines in 3D space (two or more lines). Will return point with the minimum sum of squared distances from point to lines (LSM-method, using pseudoinverse). % PA : Nx3-matrix containing starting point of N lines% PB : Nx3-matrix containing end point of N lines% P_Intersect : Best intersection point of the N lines, in least squares sense.% distances : Distances from intersection point to the input lines% Anders Eikenes, 2012

Find intersection of N lines in D-dimensional space, in least squares sense. X = lineXline(A,B) -line starts & ends as N*D X = lineXline({x y..}) -lines as D long cell of starts & ends as 2*N [X,P,R] = lineXline(..) -extra outputs [X,P,R,x,t,l] = lineXline(..) -plot outputs X: Intersection point, in least squares sense, as 1*D P: Nearest point to the intersection on each line, as N*D R: Distance from intersection to each line, as N*1 x: Intersection point X as D-long cell of coordinates {x y..} p: Nearest points P as D-long cell of coordinates {x y..} as N*1 l: Initial lines A-to-B as D-long cell of coordinates {x y..} as 2*N Remarks: -Lines are assumed to be infinite in both directions. -Finds point nearest to all lines using minimum sum of squared distances. -For parallel lines returns an arbitrary point and a warning. -For lines of length zero returns NaNs. -Comments/issues/corrections email Serge: s3rg3y@hotmail.com Example: (3 lines, 2 dimensions) [X,P,R,x,p,l] = lineXline([0 0;3 0;0 4],[5 5;0 5;5 2]); plot(x{:},'*k',p{:},'.k',l{:}) X2 = lineXline(l) %alternate input form, same results Example: (2 lines, 3 dimensions) [X,P,R,x,p,l] = lineXline(rand(2,3),rand(2,3)); plot3(x{:},'*k',p{:},'.k',l{:}) Example: (4 lines, 5 dimensions) [X,P,R] = lineXline(rand(4,5),rand(4,5))

This function offsets a 2D curve by a given amount. If your curve is plotted, you can also pass the parent axis handle and offset by a given number of points, and it will respect the on-screen proportions.This was initially developed to convert thick lines into patch objects before printing to eps to avoid problems with self-overlapping curves.

Obviously, it is nothing new. You can use Matlab's fminsearch() or Curve Fitting Toolbox. There are also many alternatives such as EzyFit for Matlab, Scilab's optimization tools, Octave's optimization tools, etc. However, as long as your current tool uses a gradient-based approach, its success rate strongly depends on starting point in the case of non-convex problems. It is then your not-so-easy job to select this point. Some time ago, I found this task quite challenging when trying to identify the Foster-type representation of the thermal transient impedance of transistors, diodes and heat sinks. So I have switched to PSO. This script illustrates evolutionary identification of the 3rd order Foster-type RC ladder network for a real-life IGBT switch. I hope that you will find it easy to modify for any curve fitting task you encounter in your engineering practice. It should be noticed that gradient-free curve fitting is nothing new and the PSO-based curve fitting is not an exception here. This is just one more interpretation of the method.

This function uses a method of determinants to find the intersection of two linear lines. Inputs into this function are coordinates of two lines (vectors) i.e. Line1 = [(x11,y11);(x12,y12)] and line2=[(x21,y21);(x22,y22)].

Comparing survival curves of two groups using the log rank test.Comparison of two survival curves can be done using a statistical hypothesis test called the log rank test. It is used to test the null hypothesis that there is no difference between the population survival curves (i.e. the probability of an event occurring at any time point is the same for each population). This function uses the Kaplan-Meier procedure to estimate the survival function (KMPLOT), so if it misses, logrank will try to download it from FEX. Created by Giuseppe Cardillo giuseppe.cardillo-edta@poste.itTo cite this file, this would be an appropriate format: Cardillo G. (2008). LogRank: Comparing survival curves of two groups using the log rank test http://www.mathworks.com/matlabcentral/fileexchange/22317

The homogeneous representation of a conic is a matrix m = [A C D; C B E; D E F] that represents the equation A x^2 + B y^2 + 2C xy + 2D x + 2Ey + F = 0Given two matrix E1 and E2 representing two conics, the code will detect all their intersections.For instance:___________________%a circle centered in the originE1 = [1 0 0; 0 1 0; 0 0 -3]%an ellipse centered in the originE2 = [1 0 0; 0 3 0; 0 0 -6]%get the four homogeneous intersectionsP = intersectConics(E1, E2)%plot the normalized pointsplot(P(1,:) ./ P(3,:) , P(2,:) ./ P(3,:), 'ro');___________________For more info: http://www.pigei.com/conics-intersectionand a detailed example describing the method: http://math.stackexchange.com/questions/316849/intersection-of-conics-using-matrix-representationA C++ open souce implementation is also present at https://bitbucket.org/pierluigi/conicsintersection___________________If this code was useful, please consider a donation:Bitcoin: 3BUD7cEnbpp15hZXbPZpdgnH11FAV1kvfi

Finds the intesection of polyhedron with a plane in y-direction with example file. The polyhedron faces should be divided into triangles. The intersection results in one or more polygons defined by vertices and edges. [VV,EE]=Polyhedron_Plane(V,F,YPlane)Input:V: (Nv,3) polyhedron vertix matrixF: (Nf,3) polyhedron faces matrixYPlane: The plane of intersection of the equation y=YPlaneOutput:VV: (Nv2,3) polygon(s) vertix matrixEE: (Ne2,3) polygon(s) edges matrix

Find the intersection points of the edges of two 2D polygons, a simple function made to follow up a Newsgroup discussion

This function returns the basis of the intersection of N subspaces defined by their bases, and the dimension of this intersection. The input basis vectors must be row vectors!Example:A = [1,1,-1,1; %<-basis vector 1,2,-1,2; %<-basic vector 2,1,-1,2];B = [1,1,1,-1; 1,-1,1,1; 3,3,1,-1];C = [1,0,1,1; 1,1,1,1]------[int,dim] = findIntersect(A,B,C)int = [1 -1 1 1]dim = 1

This code can be used to draw 3D cubic splines by only entering the points through which the spline should pass.In other words, smooth curves can be drawn by simply defining occasional points through which the curve should pass.Bezier control points are calculated automatically using the Hobby's algorithm (1986), which allows a slope and "tension" of the spline at each point to be specified explicitly if desired.

The gradient function in Matlab allows you to compute the slope of a curve along its entire length. But if your curve is a noisy one, then gradient will also be noisy. In this event one might desire to fit a moderately low order polynomial regression model in a sliding window, then differentiate that model. (Like a Savitzky-Golay filter.) All of this can be done efficiently in Matlab using filter. Note that this tool does not constrain the length of the support to be even or odd.Also, this tool uses pinv to generate the filter coefficients - a more stable and accurate methodology than does the sgolay tool on the file exchange.A few examples of movingslope in action:Estimate the first derivative using a 7 point window with first through fourth order models in the sliding window. Note that the higher order approximations provide better accuracy on this curve with no noise. t = 0:.1:1;vec = exp(t);Dvec = movingslope(vec,7,1,.1)Dvec =Columns 1 through 7 1.3657 1.3657 1.3657 1.3657 1.5093 1.668 1.8435Columns 8 through 11 2.0373 2.0373 2.0373 2.0373Dvec = movingslope(vec,7,2,.1)Dvec =Columns 1 through 7 0.95747 1.0935 1.2296 1.3657 1.5093 1.668 1.8435Columns 8 through 11 2.0373 2.2403 2.4433 2.6463Dvec = movingslope(vec,7,3,.1)Dvec =Columns 1 through 7 1.0027 1.1049 1.2206 1.3498 1.4918 1.6487 1.8221Columns 8 through 11 2.0137 2.2268 2.4602 2.7138Dvec = movingslope(vec,7,4,.1)Dvec = Columns 1 through 7 0.99988 1.1052 1.2214 1.3498 1.4918 1.6487 1.8221Columns 8 through 11 2.0137 2.2255 2.4597 2.7181Estimate the slope of a noisy curve, using a locally quadratic approximation. In this case, use a straight line so that we know the true slope should be 1. Use a moderately wide window (10 points), since we have noisy data.t = 0:100;vec = t + randn(size(t));Dvec = movingslope(vec,10,2,1)mean(Dvec)ans = 1.0013std(Dvec)ans = 0.10598By way of comparison, gradient gives a much noisier estimate of the slope of this curve.std(gradient(vec))ans = 0.69847As a time test, generate a random data vector of length 500000. Compute the slopes using a window of width 10 and a quadratic approximation in the sliding window.vec = rand(1,500000);ticDvec = movingslope(vec,10,2);tocElapsed time is 0.626021 seconds.

This function computes the intersection of a cone and a plane, where the result is represented either as an ellipse or in the form of a Gaussian distribution.This algorithm can be used to extract probabilistically information concerning gazing or pointing direction. Indeed, by representing a visual field as a cone and representing a table as a plane, the Gaussian distribution can be used to compute the probability that one object on the table is observed/pointed by the user.The source code is an implementation of the algorithms described in the book "Robot Programming by Demonstration: A Probabilistic Approach", EPFL/CRC Press (more information on http://programming-by-demonstration.org/book/)

Please first check the examples tab (.mlx file) here on the right for a complete description.Once downloaded, typewrite 'help lines_intersection' or 'doc lines_intersection' in Matlab console for support.To benefit from the file documentation attached, be sure to download the file, not to just copy and paste it.For 2D in (Oxy) plane, just padd your input data with a 0 in z dimension.Please don't forget to rate it if this code helped you. Thanks ;-)