1
$\begingroup$

I have a few set of data of three dimensional matrices, n x 3 with x, y and z coordinates. I viewed the matrices in the figure window.

% read function;
OBJ1=read_obj('subject1.obj');
FV.vertices=OBJ1.vertices;
FV.faces=OBJ1.objects(2).data.vertices;
figure, patch(FV,'facecolor',[0 0 1]); camlight
grid on
axis equal

I want to read other sets of data by using the same function, but sets the center of each figure (not the center of origin) at [x y z]=[0 0 0].

Note that when I use the function above, the center of outputs is not always at [0 0 0].

Is it can be done by using translation function?

$\endgroup$
1
$\begingroup$

If you want a perfectly square set of axes with the center at $(0,0,0)$, while keeping all of the data on screen, I'd do something like this:

axis auto;
a = axis;
amax = max(abs(a));
axis([-amax,amax,-amax,amax,-amax,amax]);

If you like your axes limits to be integral, change max(abs(a)) to ceil(max(abs(a))).

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ what if the center of 3D figure is not originally at [0 0 0]? for example: [x y z]=[29.24 -11.83 103]. can i really translate it to be [0 0 0]? $\endgroup$ – user3991 Apr 26 '13 at 3:05
  • $\begingroup$ Well, you've gotta do what looks right. But the purpose of axis auto is to get the extends of the 3-D figure. I use those to determine the smallest cube, centered at the origin, that contains the extents of the figure. $\endgroup$ – Michael Grant Apr 26 '13 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy