LoginSignup
0
1

More than 5 years have passed since last update.

MATLABでホームベース型の図形をplotする関数を作った

Posted at

MATLABでロボットのTrajectoryとかを示す時にただの線ではつまらないので以下のようなホームベース型の図形を作成したほうが視覚的にわかりやすいでしょう。

以下切り抜きにて失礼:
image.png

しかし,探してもそれらしいプログラムが落ちていないので自作しました。

自作関数

ちなみに日本語の”ホームベース”は英語では"baseball base"というのが自然そうです。

%%%
% Input: (x,y,theta) of point and baseballbase size
% Output: handle of plot
%%% 

function  handle = plot_baseballbase(x,y,theta,hsize)
d = hsize/2;
pts = [d 2*d d -d -d d;d 0 -d -d d d];
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
rpts = R*pts;

handle = plot(x+rpts(1,:),y+rpts(2,:),'k')
end

TODO

  • 本当はオプションを渡せるようにしたかったんですが…MATLABでデフォルト引数が使えないため,使い勝手がすこぶる悪い感じになりうる…
if nargin==4
option = 'default value';
end
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1