Retrieve X,Y,Z Co-ordinates from CNC Programme
3 views (last 30 days)
Show older comments
I have gone through matlab code of Laser-assisted direct ink writing of metal which is available file exchange tab, in that by reading the CNC G-codes they are converting into x,y,z data for the tool movement. Particularly, for G02 & G03 Circular Interpolation, he was used the vector method to find the angle of circle/arc. i want to know physical meaning of vector v1 and v2 and what is meaning of phase angle? Please help me.
%if G2 command (CW arc)
elseif command(1) == 2
%determine endpoint
endPos = startPos + command(2:4);
%determine arc angle and radius
v1 = [command(2), command(3)]
v2 = [-command(6), command(5)]
if norm(v1) == 0
arcAngle = 2*pi;
else
arcAngle = 2*acos(v1*transpose(v2)/(norm(v1)*norm(v2)))
end
arcRadius = norm(v2);
%determine initial phase of arc
phase = acos(([-1,0]*[command(5); command(6)])/arcRadius);
if command(6) > 0
phase = 2*pi - phase;
end
%angle increment
dtheta = ds*(arcRadius^2 + (command(4)/arcAngle)^2)^(-1/2);
theta = 0:dtheta:arcAngle;
%define x & y coordinates
array(:,1) = arcRadius*cos(phase - theta) ...
+ startPos(1) + command(5);
array(:,2) = arcRadius*sin(phase - theta) ...
+ startPos(2) + command(6);
%define z values, ensure it has same number of points as x,y
size = numel(theta);
dz = command(4)/(size-1);
array(1,3) = startPos(3);
for i = 2:size
array(i,3) = array(i-1,3) + dz;
end
0 Comments
Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!