From: <jpi...@us...> - 2011-09-27 16:05:26
|
Revision: 8619 http://octave.svn.sourceforge.net/octave/?rev=8619&view=rev Author: jpicarbajal Date: 2011-09-27 16:05:17 +0000 (Tue, 27 Sep 2011) Log Message: ----------- mechanics-1.0.0: adding test and improving docstring Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/svgpath2polygon.m trunk/octave-forge/main/mechanics/INDEX trunk/octave-forge/main/mechanics/inst/inertia_moment_ncpoly2d.m Modified: trunk/octave-forge/main/geometry/inst/svgpath2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/svgpath2polygon.m 2011-09-27 14:38:46 UTC (rev 8618) +++ trunk/octave-forge/main/geometry/inst/svgpath2polygon.m 2011-09-27 16:05:17 UTC (rev 8619) @@ -14,9 +14,9 @@ %% along with this program. If not, see <http://www.gnu.org/licenses/>. %% -*- texinfo -*- -%% @deftypefn {Function File} @var{P} = SVGpath2polygon (@var{SVGpath}) +%% @deftypefn {Function File} @var{P} = svgpath2polygon (@var{SVGpath}) %% Converts the SVG path structure @var{SVGpath} to an array of polygons -%% compatible with matGeom (@url{https://matgeom.sf.net}). +%% compatible with the geometry package and matGeom (@url{https://matgeom.sf.net}). %% %% @var{SVGpath} is a substructure of the SVG structure output by loadSVG. This %% function extracts the field named "coord" if there is only one path. If there Modified: trunk/octave-forge/main/mechanics/INDEX =================================================================== --- trunk/octave-forge/main/mechanics/INDEX 2011-09-27 14:38:46 UTC (rev 8618) +++ trunk/octave-forge/main/mechanics/INDEX 2011-09-27 16:05:17 UTC (rev 8619) @@ -1,6 +1,6 @@ mechanics >> Classical Mechanics 1D Mechanics - nloscilator + nloscillator setnloscillator pendulum setpendulum @@ -10,3 +10,4 @@ inertia_moment_poly2d inertia_moment_ncpoly2d second_moment_poly2d + Modified: trunk/octave-forge/main/mechanics/inst/inertia_moment_ncpoly2d.m =================================================================== --- trunk/octave-forge/main/mechanics/inst/inertia_moment_ncpoly2d.m 2011-09-27 14:38:46 UTC (rev 8618) +++ trunk/octave-forge/main/mechanics/inst/inertia_moment_ncpoly2d.m 2011-09-27 16:05:17 UTC (rev 8619) @@ -100,3 +100,19 @@ %! c3 = center_mass_poly2d(r3); I3 = inertia_moment_poly2d(r3,m3,c3); %! %! I1 + m1*sumsq(c1) + I2 + m2*sumsq(c2) + I3 + m3*sumsq(c3) + +%!test +%! poly = [0 0; 1 0; 1 0.25; 0.25 0.25; 0.25 0.75; 1 0.75; 1 1; 0 1]; +%! poly = poly - repmat(center_mass_poly2d(poly),size(poly,1),1); +%! A = area_poly2d(poly); +%! I = inertia_moment_ncpoly2d(poly,1) +%! % It should give (breaking C in rectangles) +%! r1 = [poly(1:3,:); poly(1,1) poly(3,2)]; a1 = area_poly2d(r1); m1 = abs(a1/A); +%! c1 = center_mass_poly2d(r1); I1 = inertia_moment_poly2d(r1,m1,c1); +%! r2 = [r1(4,:); poly(4:5,:); poly(1,1) poly(5,2)]; a2 = area_poly2d(r2); m2 = abs(a2/A); +%! c2 = center_mass_poly2d(r2); I2 = inertia_moment_poly2d(r2,m2,c2); +%! r3 = [poly(5:8,:); r2(4,:)]; a3 = area_poly2d(r3); m3 = abs(a3/A); +%! c3 = center_mass_poly2d(r3); I3 = inertia_moment_poly2d(r3,m3,c3); +%! I_shouldbe = I1 + m1*sumsq(c1) + I2 + m2*sumsq(c2) + I3 + m3*sumsq(c3); +%! assert(I,I_shouldbe) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |