oops.. It crashes when one of the lines becomes vertical. I special cased it for the first line only: http://grasshopper3d.googlegroups.com/web/Vector_Substraction_4.ghx Not very elegant, sorry, and it still breaks if the second line is vertical, but you just need to set one line vertical to be able to reproduce all cases. It also breaks if both lines are parallel, but this is expected though since you are not able to decompose the vector in this case.
On Jan 10, 6:28 pm, basbasbas <[email protected]> wrote: > mmm, your solution is not generic enough. It has a division by zero > problem when the rods are on the x and y axis. See it yourself in the > following file: > > http://groups.google.com/group/grasshopper3d/web/Vector_Substraction_... > > Cheers, Bas > > On Jan 7, 11:35 pm, visose <[email protected]> wrote: > > > This is one possible > > simplification:http://grasshopper3d.googlegroups.com/web/Vector+Substraction+2.ghx > > > I don't know if i can simplify it further without using the scripting > > component. > > > On Jan 7, 10:09 pm,basbasbas<[email protected]> wrote: > > > > Done. See the file named Vector Substraction 1.XML (zipped) or try the > > > follwing > > > link:http://grasshopper3d.googlegroups.com/web/Vector+Substraction+1.zip?h... > > > > I hope you or someone else can simplify this. > > > > Cheers Bas > > > > On Jan 7, 8:56 pm, visose <[email protected]> wrote: > > > > > Click on the 'files' link at the right hand side of this site. Then > > > > click on 'upload file' (you must be logged in). Remember to include > > > > both the .3dm and .ghx files if you are referencing any rhino > > > > geometry. > > > > > On Jan 7, 8:48 pm,basbasbas<[email protected]> wrote: > > > > > > How can I post the definition? > > > > > > On Jan 7, 8:20 pm, visose <[email protected]> wrote: > > > > > > > post the definition. maybe there's a way to optimize it. Maybe using > > > > > > the math approach and a scripting component for example. > > > > > > > On Jan 7, 8:13 pm,basbasbas<[email protected]> wrote: > > > > > > > > I hope that David is going to implement a function that creates > > > > > > > the > > > > > > > graphical approach of dividing a vector in two vectors with known > > > > > > > directions. I used quit a lot of functions to get it. (orient, > > > > > > > divide, > > > > > > > item, scale, CCX, Line, and that four times for each line of the > > > > > > > paralellogram) > > > > > > > > Cheers > > > > > > > Bas > > > > > > > > On Jan 4, 12:17 am, visose <[email protected]> wrote: > > > > > > > > > Nice one. I used maths, you used the graphical approach. Using > > > > > > > > the > > > > > > > > mathematical approach you get to use less components once you > > > > > > > > have the > > > > > > > > proper equations (it's also more useful if it starts to get too > > > > > > > > complex). Still, for simple things i prefer the graphical > > > > > > > > approach > > > > > > > > (since my math are not very good). You understand better what > > > > > > > > you are > > > > > > > > doing, it's more 'visual'. > > > > > > > > > On Jan 3, 11:43 pm,basbasbas<[email protected]> wrote: > > > > > > > > > > Thanks for this solution. In the mean while I tried another > > > > > > > > > solution, > > > > > > > > > which seems more simple. My main vector is indeed in the XY > > > > > > > > > plane. > > > > > > > > > I have drawn lines (using Orient) in the right amplitude at > > > > > > > > > both the > > > > > > > > > start point of my vector as on the end point. I have made > > > > > > > > > these lines > > > > > > > > > extremely long in both directions. > > > > > > > > > Than I cut these lines at the intersections. The length of my > > > > > > > > > new > > > > > > > > > lines are my substracted vectors. simple! Just like the old > > > > > > > > > school > > > > > > > > > days. :) > > > > > > > > > > Cheers, Bas > > > > > > > > > > On Dec 31 2008, 4:55 am, visose <[email protected]> wrote: > > > > > > > > > > > Let's see, i did it using some basic math, but maybe > > > > > > > > > > there's a simpler > > > > > > > > > > way. > > > > > > > > > > For simplification, let's say you are working on 2D and the > > > > > > > > > > XY plane, > > > > > > > > > > so you have the following equation: > > > > > > > > > > a = X*b + Y*c > > > > > > > > > > where 'a' is the initial vector, and 'b' and 'c' are the > > > > > > > > > > two unit > > > > > > > > > > vectors you want to find the magnitude (right now they are > > > > > > > > > > unit > > > > > > > > > > vectors).You want to find X and Y. > > > > > > > > > > > Since we are in 2d we have two numbers for every vector (x > > > > > > > > > > and y > > > > > > > > > > coordinates), so we actually have two formulas: > > > > > > > > > > a.x = X*b.x + Y*c.x > > > > > > > > > > and > > > > > > > > > > a.y = X*b.y + Y*c.y > > > > > > > > > > Using substitution you get the following equations: > > > > > > > > > > (a.y -a.x*c.y/c.x)/(-b.x*c.y/c.x + b.y) for X > > > > > > > > > > (a.y -a.x*b.y/b.x)/(-c.x*b.y/b.x + c.y) for Y > > > > > > > > > > Place this formulas into expression components, then use > > > > > > > > > > the magnitude > > > > > > > > > > or multiply vector components to create the two final > > > > > > > > > > components. > > > > > > > > > > > The 3 vectors must be on the same plane, but maybe they are > > > > > > > > > > not in the > > > > > > > > > > XY plane. For this i would use the 'orient' component to > > > > > > > > > > bring them to > > > > > > > > > > the x,y plane and then use it again to bring them back to > > > > > > > > > > its initial > > > > > > > > > > position. > > > > > > > > > > > There's probably a way of doing this using the vector > > > > > > > > > > components > > > > > > > > > > without so much equation, I'm not sure. > > > > > > > > > > > On Dec 30, 9:58 pm,basbasbas<[email protected]> wrote: > > > > > > > > > > > > Dear Visose, > > > > > > > > > > > > I want to decompose it to two vectors not oriented to > > > > > > > > > > > world > > > > > > > > > > > coordinates and generaly not perpendicular to my vector. > > > > > > > > > > > > Cheers, > > > > > > > > > > > Bas > > > > > > > > > > > > On 30 dec, 20:27, visose <[email protected]> wrote: > > > > > > > > > > > > > What exactly are you trying to achieve? > > > > > > > > > > > > You want to decompose the vector into two other > > > > > > > > > > > > perpendicular vectors? > > > > > > > > > > > > like when you want to calculate a diagonal force you > > > > > > > > > > > > decompose it in X > > > > > > > > > > > > and Y forces. You want to decompose it to vectors not > > > > > > > > > > > > oriented to > > > > > > > > > > > > world coordinates? > > > > > > > > > > > > You want to get the magnitude of one vector, divide it > > > > > > > > > > > > by 2, and apply > > > > > > > > > > > > it to two other vectors no matter what the direction of > > > > > > > > > > > > the first > > > > > > > > > > > > vector is? > > > > > > > > > > > > or something else? > > > > > > > > > > > > > If it's the first case it's easy, since vectors in > > > > > > > > > > > > grasshopper (and > > > > > > > > > > > > rhino) are defined by 3 perpendicular components > > > > > > > > > > > > (x,y,z) and not by > > > > > > > > > > > > magnitude and angle, you just need to use the > > > > > > > > > > > > 'decompose vector' > > > > > > > > > > > > component, no need to do any trigonometry. > > > > > > > > > > > > > On Dec 30, 6:10 pm,basbasbas<[email protected]> wrote: > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > I have a vector that I want to divide into two new > > > > > > > > > > > > > vectors with known > > > > > > > > > > > > > directions. What is the best way to proceed? > > > > > > > > > > > > > > Cheers, > > > > > > > > > > > > > Bas Goris > >
