I plotted a set of triangles using the code below:
A=[1, 1; 1, 5; 3, 9; 4, 2;9,9];
plot(A(:,1),A(:,2),'oc','LineWidth',2,'MarkerSize',5);
axis([0 10 0 10]);
grid on
for ii = 1:size(A, 1) - 1
for jj = ii + 1:size(A, 1)
line([A(ii, 1), A(jj, 1)], [A(ii, 2), A(jj, 2)])
end
end
The problem is, i will like the plot to indicate the region with the highest number of intersections. In this particular code, the region is the black polygon (i had to indicate this region manually).
Please can anyone help out with this problem. Thanks
Here is a variant with a more graphical approach.
Create a grid of points
Check the number of triangles that a point
is inside
Plot the points with highest number of intersecting
triangles
The code
% Create the combination of all points that make the triangles
% This could be used to plot the lines as well
N = size(A,1);
comb = [];
for i = 1:N-2
for j = i+1:N-1
comb = [comb; repmat([i j], N-j,1) (j+1:N)']; %#ok<AGROW>
end
end
nComb = size(comb,1);
% Create a mesh grid
dg = 0.1; % Resolution - tune this!
gridEdge = [min(A);max(A)];
[X, Y] = meshgrid(gridEdge(1,1):dg:gridEdge(2,1), gridEdge(1,2):dg:gridEdge(2,2));
% Check if a point is inside each triangle
[isInside, onEdge] = deal(zeros(numel(X),nComb));
for i = 1:nComb
[isInside(:,i), onEdge(:,i)] = inpolygon(X(:),Y(:),A(comb(i,:),1),A(comb(i,:),2));
end
% Remove points on edge
isInside = isInside - onEdge;
% Get index of points with most intersection
inTri = sum(isInside,2);
idx = find(inTri == max(inTri));
% Plot result
hold on
plot(X(idx),Y(idx),'.')
text(mean(X(idx)),mean(Y(:)),num2str(max(inTri)),'FontSize',20)
Related
I am doing a project in image processing, basically to Vectorise hand drawn images using image processing techniques.
I am using RANSAC in my project. The challenge that I am facing is that the algorithm does not perform the best fit as required but
it uses any two random points and draws a line that joins them as shown in the image below.
RANSAC results
In my algorithm to Vectorise hand drawn images, I also did Grey-scaling, Image thresholding (Image Binarization),
and Skeletonization using Morphological Operators.
I am using MATLAB for my project.
The following is the code I have done so far
% Line fitting using RANSAC
[x, y] =size(skeleton_image);
point =[];
count =1;
% figure; imshow(~data); hold on
for n =1:x
for m =1:y
if skeleton_image(n,m)==1
point(count,1)=m;
point(count,2)=n;
count= count+1;
end
end
end
data = point';
number = size(data,2); % Total number of points
X = 1:number;
iter=100; num=2; thresh = 1000;count_inlines=103; best_count=0; best_line=[];
for i=1:iter
% Randomly select 2 points
ind = randi(number,num); % randperm(number,num);
rnd_points= data(:,ind);
% Fitting line
Gradient = (rnd_points(2,2)-rnd_points(2,1))/(rnd_points(1,2)-rnd_points(1,1));
Constant = rnd_points(2,1)-Gradient*rnd_points(1,1);
Line = Gradient*X+Constant; [j,k]=size(Line);
% How many pixels are in the line?
for i=1:number
Distance = sqrt((Line(:,i)-data(1,i)).^2)+(Line(:,i)-data(2,i)).^2);
if Distance<=thresh
inlines = data(:,i);
count_inlines=countinlines+1;
best_line=Line;
end
I think your issue might be in the way you are counting the distance and/or the threshold that is currently 1000. It might choose all the points in any case and just pick the first or the last ransac line.
% Line fitting using RANSAC
%create skeleton_image objects
skeleton_image = zeros(50,50);
% draw a circle
circle_center = [15,15];
radius = 6;
for i=1:50
for j = 1:50
if abs( radius - sqrt( (i-circle_center(1))^2 + (j-circle_center(2))^2 ) ) <0.5 % < controls the thickness of the circle
skeleton_image(i,j) = 1;
endif
end
end
% draw a line
grad=0.5;
dy = 20;
for i=10:50
skeleton_image(ceil(dy + grad*i),i)=1;
if (i < 50)
skeleton_image(ceil(dy + grad*i)+1,i)=1;
endif
end
% a handful of random points to make it more realistic
skeleton_image(20,22)=1;
skeleton_image(30,7)=1;
skeleton_image(18,45)=1;
skeleton_image(10,10)=1;
skeleton_image(20,23)=1;
skeleton_image(31,6)=1;
skeleton_image(19,45)=1;
skeleton_image(9,13)=1;
skeleton_image(20,24)=1;
skeleton_image(31,5)=1;
skeleton_image(18,46)=1;
% [x, y] =size(skeleton_image);
x = 50;
y = 50;
points =[];
count =1;
for n =1:x
for m =1:y
if skeleton_image(n,m)==1
points(count,1)=m;
points(count,2)=n;
count= count+1;
end
end
end
best_line = [];
best_count = 0;
line_point_list = [];
% how close the pixel has to be to the line to be accepted
threshold = 1;
% how many samples are taken
steps = 10;
for i=1:steps
% pick two points
ind1 = randi(number,1);
ind2 = randi(number,1);
point1 = points(ind1,:);
point2 = points(ind2,:);
%auxiliaries
line = [point1;point2];
lpl = []; %line_point_list
count_i = 0;
if point1 != point2
vector1 = point2-point1;
% unit vector
vector1_normalized = vector1 ./ norm(vector1);
% normal direction of the line
normal_of_vector1 = [vector1_normalized(2), -vector1_normalized(1)];
% loop over points
for j = 1:size(points)
% calculate distance
normal_of_vector1;
vector2 = points(j,:) - point1;
distance = abs(dot(vector2, normal_of_vector1));
if ( distance < threshold )
count_i +=1;
lpl(count_i,:) = points(j,:);
endif
end
endif
if ( count_i > best_count)
best_count = count_i;
best_line = line;
line_point_list = lpl;
endif
end
%best_c
%best_l
%line_point_list
% draw found points
for i=1:size(line_point_list)
skeleton_image(line_point_list(i,2),line_point_list(i,1) ) = 0.25;
end
%visualize
figure(1)
imshow(skeleton_image)
Consider the following visualization of a 7x5 matrix consisting of 3 distinct regions/values:
bL = toeplitz( [zeros(1,5) -2*ones(1,2)], [0 -ones(1,4)] );
hF = figure(); hA = axes(hF);
imagesc(hA,bL); axis(hA,'image'); set(hA,'XTick',[],'YTick',[]);
N = 4; cmap = parula(N); colormap(cmap(1:end-1,:));
Now let's say I "select" 0 or more pixels in each column such that:
Selected pixels can only be chosen in the green region.
Selected pixels are always contiguous.
Selection is performed by assigning a constant new value, which is different from the 3 initial regions.
Several examples of selection (using the value 1):
%Example 1:
cSF = toeplitz([ones(1,1) zeros(1,4) -2*ones(1,2)],[1 -ones(1,4)]);
%Example 2:
oSF = toeplitz( [zeros(1,5) -2*ones(1,2)], [0 -ones(1,4)] );
oSF(end-2:end,find(any(oSF==-2,1),1,'last')+1:end) = 1;
%Example 3:
iSF = toeplitz([ones(1,3) zeros(1,2) -2*ones(1,2)],[1 -ones(1,4)]);
% Plot:
hF = figure();
hP(1) = subplot(1,3,1); imagesc(cSF);
hP(2) = subplot(1,3,2); imagesc(oSF);
hP(3) = subplot(1,3,3); imagesc(iSF);
axis(hP,'image'); set(hP,'XTick',[],'YTick',[]);
My objective is to draw a set of rectangles encompassing "selected" (yellow) pixels belonging to the same column. For the examples above, the results should look like this (respectively):
The way I see it, for the code to be general it should accept: (1) an axes handle where the imagesc should be plotted; (2) a data array; (3) a value found in the data array, representing "chosen" pixels; and optionally the color of the enclosed pixels.
I found some ways of doing this using patch and rectangle (see own answer), but I'm wondering if this can be achieved with fewer function calls or in other ways I hadn't thought of.
Loopless solution using patch:
Here's a solution that generates coordinates for patch without needing a loop:
function column_highlight(hA, data, selectionVal)
assert(nargin >= 2);
if (nargin < 3) || isempty(selectionVal)
selectionVal = 1;
end
nCol = size(data, 2);
data = diff([false(1, nCol); (data == selectionVal); false(1, nCol)]);
[r, c] = find(data);
r = reshape(r-0.5, 2, []);
c = c(1:2:end);
X = [c-0.5 c+0.5 c+0.5 c-0.5].';
Y = r([1 1 2 2], :);
patch(hA, 'XData', X, 'YData', Y, 'FaceColor', 'none');
end
Solution using regionprops:
If you have the Image Processing Toolbox, you can solve this by labeling each masked column section and getting the 'BoundingBox' shape measure using regionprops:
function column_highlight(hA, data, selectionVal)
assert(nargin >= 2);
if (nargin < 3) || isempty(selectionVal)
selectionVal = 1;
end
labelMat = bsxfun(#times, (data == selectionVal), 1:size(data, 2));
coords = regionprops(labelMat, 'BoundingBox');
coords = vertcat(coords.BoundingBox);
coords(:, 3:4) = coords(:, 1:2)+coords(:, 3:4);
X = coords(:, [1 3 3 1]).';
Y = coords(:, [4 4 2 2]).';
patch(hA, 'XData', X, 'YData', Y, 'FaceColor', 'none');
end
A solution using rectangle:
function markStreaksRect(hA, data, selectionVal)
% Check inputs:
assert(nargin >= 2); if nargin < 3 || isempty(selectionVal), selectionVal = 1; end
% Create a mask for "selected" values:
oneMask = data == selectionVal;
% Find the first encountered "selected" element from both the top and the bottom:
[~,I1] = max(oneMask,[],1); [~,I2] = max(flipud(oneMask),[],1);
% Express the "selected" extent as a 2 row vector:
firstLast = [I1; size(oneMask,1)-I2+1].*any(oneMask,1);
% For nonzero extents, plot shifted rectangles:
for ind1 = find(all(firstLast,1))
rectangle(hA,'Position',[ind1-0.5, firstLast(1,ind1)-0.5, 1, diff(firstLast(:,ind1))+1 ]);
end
A solution using patch:
function markStreaksPatch(hA, data, selectionVal)
% Check inputs:
assert(nargin >= 2); if nargin < 3 || isempty(selectionVal), selectionVal = 1; end
% Create a mask for "selected" values:
oneMask = data == selectionVal;
% Find the first encountered "selected" element from both the top and the bottom:
[~,I1] = max(oneMask,[],1); [~,I2] = max(flipud(oneMask),[],1);
% Express the "selected" extent as a 2 row vector:
firstLast = [I1; size(oneMask,1)-I2+1].*any(oneMask,1);
% For nonzero extents, plot shifted patches:
for ind1 = find(all(firstLast,1))
[XX,YY] = meshgrid(ind1-0.5 + [0 1], firstLast(1,ind1)-0.5+[0 diff(firstLast(:,ind1))+1]);
patch(hA, XX(:), [YY(1:2) YY(4:-1:3)], 'y', 'FaceAlpha', 0);
end
The above solutions can be tested using:
function q45965920
iSF = toeplitz([ones(1,3) zeros(1,2) -2*ones(1,2)],[1 -ones(1,4)]);
hF = figure(); hA = axes(hF); imagesc(hA,iSF);
axis(hA,'image'); set(hA,'XTick',[],'YTick',[]);
...then running either markStreaksRect(hA, iSF, 1); or markStreaksPatch(hA, iSF, 1); produces the desired result.
Here's what I get by using the treeplot function on MATLAB (this is the example image):
Here's what I'd like to get:
As you can see, I'd like to have the position of each node according to its distance from the root. Is that possible?
I was also looking for a "root-aligned" treeplot in Matlab and found no solution. Here is what I came up with, in case someone is still in need of it (I'm using the same example as in the Matlab documentation):
nodes = [0 1 2 2 4 4 4 1 8 8 10 10];
At first we need to get the x and y coordinates of every node in the original tree plot and find all leaves in it:
[x,y] = treelayout(nodes);
leaves = find( y == min(y) );
Next, we reconstruct every chain in the tree plot and store it in a matrix (by doing so, we can later change the y position of the nodes):
num_layers = 1/min(y)-1;
chains = zeros(num_layers, length(leaves));
for l=1:length(leaves)
index = leaves(l);
chain = [];
chain(1) = index;
parent_index = nodes(index);
j = 2;
while (parent_index ~= 0)
chain(j) = parent_index;
parent_index = nodes(parent_index);
j = j+1;
end
chains(:,l) = padarray(flip(chain), [0, num_layers-length(chain)], 'post');
end
Now we compute the new y-coordinates determined by the row index in the matrix and dependent on the number of layers in the tree:
y_new = zeros(size(y));
for i=1:length(nodes)
[r,c] = find(chains==i, 1);
y_new(i) = max(y) - (r-1)*1/(num_layers+1);
end
We can now plot the re-positioned nodes and add the connecting lines:
plot(x, y_new, 'o');
hold on
for c=1:size(chains, 2)
line_x = x(chains(chains(:,c)>0, c));
line_y = y_new(chains(chains(:,c)>0, c));
line(line_x, line_y);
end
If you like, you can also add the node labels to the plot:
for t=1:length(nodes)
text(x(t)+0.025, y_new(t), num2str(t));
end
xlim([0 1]);
ylim([0 1]);
The resulting figure looks as follows:
Using the imfindcircles function in MATLAB to track circles in two images. I start with approximately a grid of circles which deforms. I am trying to sort the two column vector from imfindcircles into matrices so that neighbouring circles are neighbouring elements in the matrices. The first image the circles conform to a grid and the following code works:
[centXsort,IX] = sortrows(centres1,1); %sort by x
centYsort =zeros(289,2); %preallocate
for i = 1:17:289
[sortedY,IY] = sortrows(centXsort(i:i+16,:),2); %sort by y within individual column
centYsort(i:i+16,:) = sortedY;
end
cent1mat = reshape(centYsort,17,17,2); %reshape into centre matrices
This doesn't work for the second image as some of the circles overlap in the x or y direction, but neighbouring circles never overlap. This means that in the second set of matrices the neighbouring circles aren't neighbouring elements after sorting.
Is there a way to approximate a scatter of points into a matrix?
This answer doesn't work in every single case, but it seems good enough for situations where the points don't vary too wildly.
My idea is to start at the grid corners and work our way along the outside diagonals of the matrix, trying to "grab" the nearest points that seem like they fit into the grid-points based any surrounding points we've already captured.
You will need to provide:
The number of rows (rows) and columns (cols) in the grid.
Your data points P arranged in a N x 2 array, rescaled to the unit square on [0,1] x [0,1]. (I assume the you can do this through visual inspection of the corner points of your original data.)
A weight parameter edge_weight to tell the algorithm how much the border points should be attracted to the grid border. Some tests show that 3-5 or so are good values.
The code, with a test case included:
%// input parameters
rows = 11;
cols = 11;
edge_weight = 4;
%// function for getting squared errors between the points list P and a specific point pt
getErr =#(P,pt) sqrt( sum( bsxfun(#minus,P,pt(:)').^2, 2 ) ); %'
output_grid = zeros(rows,cols,2); %// output grid matrix
check_grid = zeros(rows,cols); %// matrix flagging the gridpoints we have covered
[ROW,COL] = meshgrid(... %// coordinate points of an "ideal grid"
linspace(0,1,rows),...
linspace(0,1,cols));
%// create a test case
G = [ROW(:),COL(:)]; %// the actual grid-points
noise_factor = 0.35; %// noise radius allowed
rn = noise_factor/rows;
cn = noise_factor/cols;
row_noise = -rn + 2*rn*rand(numel(ROW),1);
col_noise = -cn + 2*cn*rand(numel(ROW),1);
P = G + [row_noise,col_noise]; %// add noise to get points
%// MAIN LOOP
d = 0;
while ~isempty(P) %// while points remain...
d = d+1; %// increase diagonal depth (d=1 are the outer corners)
for ii = max(d-rows+1,1):min(d,rows)%// for every row number i...
i = ii;
j = d-i+1; %// on the dth diagonal, we have d=i+j-1
for c = 1:4 %// repeat for all 4 corners
if i<rows & j<cols & ~check_grid(i,j) %// check for out-of-bounds/repetitions
check_grid(i,j) = true; %// flag gridpoint
current_gridpoint = [ROW(i,j),COL(i,j)];
%// get error between all remaining points and the next gridpoint's neighbours
if i>1
errI = getErr(P,output_grid(i-1,j,:));
else
errI = edge_weight*getErr(P,current_gridpoint);
end
if check_grid(i+1,j)
errI = errI + edge_weight*getErr(P,current_gridpoint);
end
if j>1
errJ = getErr(P,output_grid(i,j-1,:));
else
errJ = edge_weight*getErr(P,current_gridpoint);
end
if check_grid(i,j+1)
errJ = errJ + edge_weight*getErr(P,current_gridpoint);
end
err = errI.^2 + errJ.^2;
%// find the point with minimal error, add it to the grid,
%// and delete it from the points list
[~,idx] = min(err);
output_grid(i,j,:) = permute( P(idx,:), [1 3 2] );
P(idx,:) = [];
end
%// rotate the grid 90 degrees and repeat for next corner
output_grid = cat(3, rot90(output_grid(:,:,1)), rot90(output_grid(:,:,2)));
check_grid = rot90(check_grid);
ROW = rot90(ROW);
COL = rot90(COL);
end
end
end
Code for plotting the resulting points with edges:
%// plotting code
figure(1); clf; hold on;
axis([-0.1 1.1 -0.1 1.1])
for i = 1:size(output_grid,1)
for j = 1:size(output_grid,2)
scatter(output_grid(i,j,1),output_grid(i,j,2),'b')
if i < size(output_grid,1)
plot( [output_grid(i,j,1),output_grid(i+1,j,1)],...
[output_grid(i,j,2),output_grid(i+1,j,2)],...
'r');
end
if j < size(output_grid,2)
plot( [output_grid(i,j,1),output_grid(i,j+1,1)],...
[output_grid(i,j,2),output_grid(i,j+1,2)],...
'r');
end
end
end
I've developed a solution, which works for my case but might not be as robust as required for some. It requires a known number of dots in a 'square' grid and a rough idea of the spacing between the dots. I find the 'AlphaShape' of the dots and all the points that lie along the edge. The edge vector is shifted to start at the minimum and then wrapped around a matrix with the corresponding points are discarded from the list of vertices. Probably not the best idea for large point clouds but good enough for me.
R = 50; % search radius
xy = centres2;
x = centres2(:,1);
y = centres2(:,2);
for i = 1:8
T = delaunay(xy); % delaunay
[~,r] = circumcenter(triangulation(T,x,y)); % circumcenters
T = T(r < R,:); % points within radius
B = freeBoundary(triangulation(T,x,y)); % find edge vertices
A = B(:,1);
EdgeList = [x(A) y(A) x(A)+y(A)]; % find point closest to origin and rotate vector
[~,I] = min(EdgeList);
EdgeList = circshift(EdgeList,-I(3)+1);
n = sqrt(length(xy)); % define zeros matrix
matX = zeros(n); % wrap x vector around zeros matrix
matX(1,1:n) = EdgeList(1:n,1);
matX(2:n-1,n) = EdgeList(n+1:(2*n)-2,1);
matX(n,n:-1:1) = EdgeList((2*n)-1:(3*n)-2,1);
matX(n-1:-1:2,1) = EdgeList((3*n)-1:(4*n)-4,1);
matY = zeros(n); % wrap y vector around zeros matrix
matY(1,1:n) = EdgeList(1:n,2);
matY(2:n-1,n) = EdgeList(n+1:(2*n)-2,2);
matY(n,n:-1:1) = EdgeList((2*n)-1:(3*n)-2,2);
matY(n-1:-1:2,1) = EdgeList((3*n)-1:(4*n)-4,2);
centreMatX(i:n+i-1,i:n+i-1) = matX; % paste into main matrix
centreMatY(i:n+i-1,i:n+i-1) = matY;
xy(B(:,1),:) = 0; % discard values
xy = xy(all(xy,2),:);
x = xy(:,1);
y = xy(:,2);
end
centreMatX(centreMatX == 0) = x;
centreMatY(centreMatY == 0) = y;
For documentation purpose I'd like to show the various spherical coordinates systems that can be used to describe a position on a sphere (i.e. position can be described as xyz-coordinates or roll-over-azimuths, azimuth-over-elevation or elevation-over-azimuth, etc).
I did not find clear illustrations on the .net, especially for non-regular conventions, and I'd like to use matlab to create simple illustrations like the following one (roll-over-azimuth system) which, imao, is straightforward to understand :
Anyhow I was wondering how I can create the curved arrows to show the angular direction (phi/theta arrows in above illustration). Drawing straight vectors using quiver3 is ok. I tried reading about stream3 but did not get the point about usage. I'd like to have something simple like:
function [h] = CreateCurvedArrow(startXYZ, endXYZ)
%[
% Draw curved-line in the plane defined by
% vectors 'Origin->StartXYZ' and 'Origin->EndXYZ'
% going from 'StartXYZ' to 'EndXYZ'
%]
I hope there's some easy way to do it else I'll work-around using line segments.
Simply for the fun of doing it:
The algorithm slowy rotates Center->StartPoint vector toward Center->EndPoint vector around their Normal axis and uses intermediate points to draw the curved arrow. Implementation can be further improved of course:
function [] = TestCurvedArrow()
%[
hold on
CreateCurvedArrow3(0.3*[1 0 0], 0.3*[0 1 0]);
CreateCurvedArrow3(0.2*[0 1 0], 0.2*[0 0 1]);
CreateStraightArrow([0 0 0], [1 0 0], 'r');
CreateStraightArrow([0 0 0], [0 1 0], 'g');
CreateStraightArrow([0 0 0], [0 0 1], 'b');
hold off
daspect([1 1 1]);
%]
end
%% --- Creates a curved arrow
% from: Starting position - (x,y,z) upplet
% to: Final position - (x,y,z) upplet
% center: Center of arc - (x,y,z) upplet => by default the origin
% count: The number of segment to draw the arrow => by default 15
function [h] = CreateCurvedArrow3(from, to, center, count)
%[
% Inputs
if (nargin < 4), count = 15; end
if (nargin < 3), center = [0 0 0]; end
center = center(:); from = from(:); to = to(:);
% Start, stop and normal vectors
start = from - center; rstart = norm(start);
stop = to - center; rstop = norm(stop);
angle = atan2(norm(cross(start,stop)), dot(start,stop));
normal = cross(start, stop); normal = normal / norm(normal);
% Compute intermediate points by rotating 'start' vector
% toward 'end' vector around 'normal' axis
% See: http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/
phiAngles = linspace(0, angle, count);
r = linspace(rstart, rstop, count) / rstart;
intermediates = zeros(3, count);
a = center(1); b = center(2); c = center(3);
u = normal(1); v = normal(2); w = normal(3);
x = from(1); y = from(2); z = from(3);
for ki = 1:count,
phi = phiAngles(ki);
cosp = cos(phi); sinp = sin(phi);
T = [(u^2+(v^2+w^2)*cosp) (u*v*(1-cosp)-w*sinp) (u*w*(1-cosp)+v*sinp) ((a*(v^2+w^2)-u*(b*v+c*w))*(1-cosp)+(b*w-c*v)*sinp); ...
(u*v*(1-cosp)+w*sinp) (v^2+(u^2+w^2)*cosp) (v*w*(1-cosp)-u*sinp) ((b*(u^2+w^2)-v*(a*u+c*w))*(1-cosp)+(c*u-a*w)*sinp); ...
(u*w*(1-cosp)-v*sinp) (v*w*(1-cosp)+u*sinp) (w^2+(u^2+v^2)*cosp) ((c*(u^2+v^2)-w*(a*u+b*v))*(1-cosp)+(a*v-b*u)*sinp); ...
0 0 0 1 ];
intermediate = T * [x;y;z;r(ki)];
intermediates(:,ki) = intermediate(1:3);
end
% Draw the curved line
% Can be improved of course with hggroup etc...
X = intermediates(1,:);
Y = intermediates(2,:);
Z = intermediates(3,:);
tf = ishold;
if (~tf), hold on; end
h = line(X,Y,Z);
quiver3(X(end-1), Y(end-1), Z(end-1), X(end)-X(end-1), Y(end)-Y(end-1), Z(end)-Z(end-1),1);
if (~tf), hold off; end
%]
end
%% --- Creates normal arrow
% from: Starting position - (x,y,z) upplet
% to: Final position - (x,y,z) upplet
% lineSpec: Line specifications
function [h] = CreateStraightArrow(from, to, lineSpec)
%[
h = quiver3(from(1), from(2), from(3), to(1)-from(1), to(2)-from(2), to(3)-from(3), lineSpec);
%]
end