Question
Provided is a skeleton code to move a solidworks ascii part file across a line within MATLAB. However, I am unfamiliar with MATLAB coding within
Provided is a skeleton code to move a solidworks ascii part file across a line within MATLAB. However, I am unfamiliar with MATLAB coding within the skeleton code and do not understand portions of the code. Specifically, how to access the solidworks part file within MATLAB. I understand that the solution cannot be posted as you do not have a part file, but a general format or advice for programming would be much appreciated. I am very lost. I posted the exact question for a better idea of the problem. Thank you.
Skeleton Code:
clear all clc
% Add working directories to current path newD = fullfile(pwd,'../'); addpath(genpath(newD));
% File names of the CAD geometry to convert to polygons FileName = {'cylinder.STL'};
% Converts CAD geometry into multiple polygons and into its vertices % The vertices all ready include the bottom row of ones, % that is V = [Pnts;1] [P,V] = cad2polyRev(FileName);
% using scaling matrix % Sx = 0.5; sy = 0.5; sz = 0.5; %V{1} = [sx 0 0 0 ;0 sy 0 0;0 0 sz 0;0 0 0 1]*V{1};
% Color options yellow,magenta,cyan,red,green,blue,white, black set(P(1),'FaceColor','magenta') % set color of filename geometry
fprintf(' Animation is ready!! Please hit return to continue. ') pause
% Set axis manually axis([-1 6 -.25 1]); hold on;
%View in 2-D view(2); %
h0 = []; % Animated robot title('Rolling Wheel') r = 0.5; %radius of the wheel dx = 0.05; % change in x coordinate cw = -1; % clockwise
% Allocate memory for vectors npts = 100; x = inf(1,npts); y =inf(1,npts); theta = inf(1,npts);
for k = 1:npts, % Center of the whe x(k) = (k-1)*dx; y(k) = r; theta(k) = cw*(x(k)/r)*180/pi;% Rotate wheel clockwise drawWheel(P,V,theta(k),x(k),y(k)) %draws road path h = plot(x(1:k),y(1:k)-r,'-'); % Deletes previous line used to draw road path set(h0, 'XData', [], 'YData', []) drawnow() h0 = h; % pause program for .05 sec to see animation pause(.05) end % End AnimateWheel.m
Problem 1: Download the sample Matlab code used to animate a wheel on the road, shown in Figure 1. Understand how the program works and what homogeneous transformations are necessary to achieve the animation. 0.5 4 Figure 1: Rolling Wheel Animation Problem 2: Modify the program files from Problem 1 and animate a roller coaster that is traveling on a sinusoid track as depicted in Figure 2 15 20 30 Figure 2: Roller coaster Animation The track is defined mathematically as y(x)-4sin(x/4), where 0-x-40. Your roller coaster animation must travel the length of the track and the center of the roller coaster (denoted by the Problem 1: Download the sample Matlab code used to animate a wheel on the road, shown in Figure 1. Understand how the program works and what homogeneous transformations are necessary to achieve the animation. 0.5 4 Figure 1: Rolling Wheel Animation Problem 2: Modify the program files from Problem 1 and animate a roller coaster that is traveling on a sinusoid track as depicted in Figure 2 15 20 30 Figure 2: Roller coaster Animation The track is defined mathematically as y(x)-4sin(x/4), where 0-x-40. Your roller coaster animation must travel the length of the track and the center of the roller coaster (denoted by theStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started