www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@constar/constraintDistance.m
function d = constraintDistance(con, X) %CONSTRAINTDISTANCE Signed distance to constraint boundary for a list of points % % D = CONSTRAINTDISTANCE(CON, X) is the signed distance to the boundary of the % constraint CON for the list of points X. This method constitutes the core % definition of the constraint in terms of what is in and what is out. % % X should be an array with nFactors( CON ) columns. D will be a vector with % the same number of rows as X. % % See also CONSTAR, CONBASE/CONSTRAINTDISTANCE, CONBASE/ISINSIDE, % CONSTAR/BRINGINSIDE. % Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc. if isempty( con.Model ), d = repmat( Inf, size( X, 1 ), 1 ); return end X = pFilterFactors( con, X ); X = pCodeData( con, X ); % Project onto sphere and find radii [YY, r] = map_to_sphere( X ); % Evaluate sphereical based interpolant R = eval( con.Model, YY ); R = transform_radius( R, con.Transform, 'Inverse' ); d = r - R - con.Offset; %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|