Line resource construction examplesΒΆ
Example 1: Create a basic Steno3D Line resource
lin = steno3d.core.Line;
verts = [0:30; sin(0:30); cos(0:30)]';
segs = [1:30; 2:31]';
mesh = steno3d.core.Mesh1D;
mesh.Vertices = verts;
mesh.Segments = segs;
lin.Mesh = mesh;
example1 = steno3d.core.Project;
example1.Resources = lin;
clear lin verts segs mesh;
Example 2: Create a Line resource and set display options
lin = steno3d.core.Line;
lin.Title = 'Example 2 Line';
lin.Description = 'This Line resource will be yellow tubes';
mesh = steno3d.core.Mesh1D;
mesh.Vertices = [0:30; sin(0:30); cos(0:30)]';
mesh.Segments = [1:30; 2:31]';
lin.Mesh = mesh;
lin.Opts.Color = 'y';
lin.Opts.Opacity = 0.75;
lin.Mesh.Opts.ViewType = 'tube';
example2 = steno3d.core.Project;
example2.Title = 'Example 2';
example2.Description = 'Project with a line';
example2.Resources = lin;
clear lin mesh;
Example 3: Create a Line resource with node data
Note
This constructor encapsulates all the features of lin from Example 2.
lin = steno3d.core.Line( ...
'Title', 'Example 3 Line', ...
'Description', 'This Line resource will have data', ...
'Mesh', steno3d.core.Mesh1D( ...
'Vertices', [0:30; sin(0:30); cos(0:30)]', ...
'Segments', [1:30; 2:31]', ...
'Opts', {'ViewType', 'tube'} ...
), ...
'Opts', {'Color', 'y', 'Opacity', 0.75} ...
);
cosdata = steno3d.core.DataArray( ...
'Title', 'Cosine Values', ...
'Array', cos(0:30)' ...
);
lin.Data = {'Location', 'N', 'Data', cosdata};
example3 = steno3d.core.Project( ...
'Title', 'Example 3', ...
'Description', 'Project with a line', ...
'Resources', lin ...
);
clear lin cosdata;
Example 4: Create a Steno3D Line with multiple datasets.
Note
There are a couple new features introduced in this consolidated construction. (1) Multiple datasets are assigned as a cell array. (2) Passing cell arrays of parameters (e.g. for Mesh) implicitly calls the correct constructor.
lin = steno3d.core.Line( ...
'Title', 'Example 4 Line', ...
'Description', 'This Line resource will have data', ...
'Mesh', {'Vertices', [0:30; sin(0:30); cos(0:30)]', ...
'Segments', [1:30; 2:31]', ...
'Opts', {'ViewType', 'tube'}}, ...
'Opts', {'Color', 'y', 'Opacity', 0.75}, ...
'Data', {{ ...
'Location', 'CC', ...
'Data', { ...
'Title', 'CC Sine Data', 'Array', cos(.5:29.5)' ...
} ...
}, { ...
'Location', 'N', ...
'Data', { ...
'Title', 'Node Cosine Data', 'Array', cos(0:30)' ...
} ...
}} ...
);
example4 = steno3d.core.Project( ...
'Title', 'Example 4', ...
'Description', 'Project with a line', ...
'Resources', lin ...
);
clear lin;
You can run the above examples with:
steno3d.examples.core.line
Then plot the projects with:
example1.plot(); % etc...
See also steno3d.core.Line, steno3d.core.Mesh1D, steno3d.core.Project, steno3d.core.DataArray