nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.22k stars 233 forks source link

Rotate and Scale #354

Closed AgustinJB closed 10 years ago

AgustinJB commented 10 years ago

Hi guys!

I know that matrix is a very powerful tool, but sometimes it's kind of difficult to use and understand. Thinking in that, I've made two nodes for general rotation and scaling in space. Both based on a center point, and rotation also in an arbitrary direction.

I've made a new branch so you can test it and tell me what you think. nodes rotate

AgustinJB commented 10 years ago

Ok, now I think it works just like in 3d view: quat

It's kind of tricky to understand quaternions...

@ly29 I don't understand what you mean about the reorder of the inputs.

mifth commented 10 years ago

@AgustinJB sorry for late responce. I tested. It seems Rotation Node works ok now.

AgustinJB commented 10 years ago

I'm glad to hear @mifth. I'll test it some more before pushing to master.

In the meanwhile I'm trying with mirror node: mirror Does someone know if I can use enumproperty and select various options at the same time? Or I have to use boolproperty for doing that?

zeffii commented 10 years ago

@AgustinJB have a look at index visualizer (viewer_indices.py)

AgustinJB commented 10 years ago

Thank you for the tip @zeffii!!

I've added mirror node: mirror

It's in early stages, but it works pretty well. Maybe I should add edge and poly inputs/outputs, and maybe study clipping and merging options.

I've been looking at the source code of mirror modifier, but right now it's hard to understand to me, so I'm not sure if it could be usefull to the rest of the options.

nortikin commented 10 years ago

@AgustinJB will there be mirror from plane/point? because there are three type of mirror:

  1. around point - _center_of_mirroring-delta(vector1, center_ofmirroring)
  2. around axis - this is kind of rotation, but like this http://www.mathsisfun.com/geometry/reflection.html only in 3d
  3. around plane, this means what you have done, but plane - is matrix or if you'd like, in matrix socket could be inserted center and vector from center... so you can define plane
mifth commented 10 years ago

Also, if set scaleX = -1.0 to Matrix.... possibly it will be like a mirror?

nortikin commented 10 years ago

@mifth it is if you scale around local zero, but if you need define some other center point?

mifth commented 10 years ago

then i dunno know :(

AgustinJB commented 10 years ago

@nortikin I'll look into that mirrors modes tomorrow. I also want to get clipping working.

AgustinJB commented 10 years ago

I've added clipping option. It need some fixing for multiple center inputs, but it works pretty well I think.

Do you think edge/polys inputs/outputs should be added?? Right now it's needed just a list repeater.

nortikin commented 10 years ago

no need to add edges and polygons, but only for flipping normal (reverse plygons indexes)

AgustinJB commented 10 years ago

@nortikin I've been looking into those others symmetry methods. Are they the ones described in this web: http://www.mathsisfun.com/geometry/symmetry.html

Because I think the last two can be made with rotation Axis/Angle, which is in rotation node. captura de pantalla de 2014-07-30 11 10 50

Maybe I can add the option to input a matrix to define an arbitrary plane of mirroring?

nortikin commented 10 years ago

@AgustinJB you have to understand that 2d is not 3d https://drive.google.com/file/d/0B6KMvjWAjGiyb1k2NHVXMnJPajg/edit?usp=sharing here is explanation. as i can drew.

nortikin commented 10 years ago

sorry, just mirroring blend uploaded new file the same link. mirror over point fixed

AgustinJB commented 10 years ago

Uhmm, right, I see. Yep, I'll do that!

nortikin commented 10 years ago

1,2,3 points. depending on how many points it builds mirror. Or if matrix inserted in the same socket, it should consider it as plane, as three points. it is my proposal, but you make as you see

nortikin commented 10 years ago

total - two sockets - one for vertices, one for point/line/plane/matrix or three - for polygons to make them reverse slice polygon[::-1]

AgustinJB commented 10 years ago

Ok, I got the three methods now:

mirror_vertex mirror_axis mirror_plane

It needs some testing, but my first tests were ok. I'm not sure if clipping has sense now.

nortikin commented 10 years ago

WOW!!!!!! will test

nortikin commented 10 years ago
Traceback (most recent call last):
  File "/home/nikitron/.config/blender/2.71/scripts/addons/sverchok-master/nodes/basic_view/viewer.py", line 217, in update
    cache_viewer_baker[n_id+'m'] = dataCorrect(propm)
  File "/home/nikitron/.config/blender/2.71/scripts/addons/sverchok-master/data_structure.py", line 288, in dataCorrect
    if dept < 2:
TypeError: unorderable types: NoneType() < int()

when matrix not connected Everything works well

AgustinJB commented 10 years ago

Oh, right, I forgot to add a default matrix. I'll add it later.

AgustinJB commented 10 years ago

I've been testing all the new nodes again and they seem to work properly. If you are ok, I will merge this branch with master, leaving new nodes in beta tab.

nortikin commented 10 years ago

yes