Help us understand the problem. What is going on with this article?

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

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
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away