AlanW Posted September 3, 2016 Share Posted September 3, 2016 Hi, there is a node that measures between 2 points in 2D but can't seem to find out how to measure between 2 Vectors. (eg, (0, 20,30) & (60, 200,300). Thanks in advance Quote Link to comment
twk Posted September 3, 2016 Share Posted September 3, 2016 (edited) http://www.intmath.com/vectors/7-vectors-in-3d-space.php def get_length_2_3DPts(Pt1, Pt2): # lngth = sqrt --> sqrd(x2-x1) + sqrd(y2-y1) +sqrd(z2-z1) def square_cust(n1, n2): return vs.Sqr(n2 - n1) lngth = vs.Sqrt(square_cust(Pt2[0], Pt1[0]) + square_cust(Pt2[1], Pt1[1]) + square_cust(Pt2[2], Pt1[2])) return lngth Edited September 3, 2016 by twk fixed Quote Link to comment
AlanW Posted September 3, 2016 Author Share Posted September 3, 2016 Hi, Thanks for this. I have tried to format a node with this but I don't seem to be able to get an output distance. Can you have a look at the node please. Thanks Distance 3D.vwx Quote Link to comment
Kevin McAllister Posted September 4, 2016 Share Posted September 4, 2016 (edited) Alan, Try this. I think the code above represents a function you would call to get a result. I took out that formatting and just made it the code of the node instead. It seems to work as expected (The file also includes a version of the node where the function is called. I suspect in this case it should actually be cleaned up to remove the duplicate variable names etc.. The first version is way cleaner for a node.) Kevin Distance 3D KM.vwx Edited September 9, 2016 by Kevin McAllister Re-uploaded file to fix broken link issue Quote Link to comment
twk Posted September 4, 2016 Share Posted September 4, 2016 @Alan Woodwell, @Kevin McAllister 's version is correct. Apologies, I forgot I was in the Marionette section. Quote Link to comment
AlanW Posted September 4, 2016 Author Share Posted September 4, 2016 (edited) Thanks, Amazing what removing one line of code can do. We just need to change the heading to "Get 3D Distance" as it actually calculated the length of the line in 3D. Edited September 4, 2016 by Alan Woodwell Rename Node Quote Link to comment
Kevin McAllister Posted September 4, 2016 Share Posted September 4, 2016 (edited) @Alan Woodwelldid you see this link to an article about vectors in Vectorscript? @MarissaFit would be great if there was a way to have some articles like this that relate to Marionette. I'm not sure what this resource actually is as its not the official Developer Wiki... Kevin Edited September 4, 2016 by Kevin McAllister The link wasn't to the official Developer Wiki but some sort of third party Wiki.... Quote Link to comment
AlanW Posted September 4, 2016 Author Share Posted September 4, 2016 (edited) No, but thanks. This sort of stuff really makes the brain work overtime and once you understand the concept things become clearer. Edited September 4, 2016 by Alan Woodwell Quote Link to comment
twk Posted September 4, 2016 Share Posted September 4, 2016 With regards to the Vectorlab.info website; I myself had wondered what it was as well. From the guy who created it :@orso b. schmid Quote No Tui, we are 'tolerated' by Nemetschek. Never acknowledged, not once. But never forget: initially all was done by Frank Brault, who moved on to other Nemetschek tasks. Also we are tolerated because there is obviously no intention to compete with the Developer Wiki. I am myself a passionate (read obsessed) editor on dev, which I beg you to consult, when it's about the singular routines. https://forum.vectorworks.net/index.php?/topic/42750-does-anybody-know-whats-on-with-vectorlabinfo/&do=findComment&comment=216461 It really is an invaluable resource, and in my opinion should be acknowledged at least by the Vectorworks Devs; For example, on this page : http://www.vectorlab.info/index.php?title=Index_pitfalls; It clearly states the problems one might encounter with regards to Index and certain vectorscript/SDK calls(procedures/functions).. 2 Quote Link to comment
Kevin McAllister Posted September 5, 2016 Share Posted September 5, 2016 Its interesting to hear the background of it and its sadly true that the Developer Wiki has its challenges. I found my experiments with Vectorscript a few years ago frustrating because of the poor documentation. Ultimately something is going to have to happen for Marionette to reach its full potential with end users. Kevin 1 Quote Link to comment
AlanW Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) Searching through the VS:Function Reference I came across another way to measure between 2 3D points. Node Attached. Just another way. For me its all about the learning, so yes maybe a long winded way to do something but I learnt a bit in the process. Distance 3D_V001.vwx Edited September 10, 2016 by Alan Woodwell Quote Link to comment
Marionette Maven Marissa Farrell Posted September 10, 2016 Marionette Maven Share Posted September 10, 2016 You guys put a lot more work into this than I have for getting a distance, haha I usually just use the two points as input for a line (or NURBs curve) and use the length node from the object info category (I apologize if my node name/location are incorrect, I'm doing this by memory...). After I've returned the length, I just delete the line/NURBs. I guess it's the lazy in me! 1 Quote Link to comment
AlanW Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) I guess there is always something to learn. Edited September 10, 2016 by Alan Woodwell Quote Link to comment
Kevin McAllister Posted September 10, 2016 Share Posted September 10, 2016 Thanks for sharing. I find it interesting to hear about all the different ways to do something. Marissa, your way is super simple! In the end though, it is good to discover the most efficient way if you're using heavy VW files. Extra code, nodes or objects to delete could become a liability if there were 100 separate instances of your Marionette object in your 200mb file Kevin Quote Link to comment
AlanW Posted September 10, 2016 Author Share Posted September 10, 2016 (edited) Hi, is there a faster and more efficient way to get the distance 3D than what I have in the attachment. I cant seem to get the network to less than 2 main nodes without using the new node. Distance 3D.vwx Edited September 10, 2016 by Alan Woodwell . Quote Link to comment
Hippocode Posted September 11, 2016 Share Posted September 11, 2016 I'm not actively using marionette but isn't there a magnitude node present in the default nodes folder under "math" ? I would be surprised if there isn't as this is a really basic math function. As a general rule, I wouldn't create and delete objects for the sake of calculating something. You might even run into objects being restated when you undo one step and this isn't a performance friendly solution. Magnitude |v| = √( x2 + y2 + z2 ) The magnitude is calculated with the vector between your two points, being v2-v1. 1 Quote Link to comment
DomC Posted September 11, 2016 Share Posted September 11, 2016 What about the native "Distance" Node? 2 Quote Link to comment
AlanW Posted September 11, 2016 Author Share Posted September 11, 2016 (edited) Ello, Where did you find this one?? Don't worry found it. And yes works a treat. The best thing about all these questions is gaining knowledge as to whats available to me in the program when faced with a problem. More choices. Thanks to all for your comments and contributions. Hippocode, what you have suggested is what is actually in the Distance node that DomC pointed out and the best thing is I can see how to put that formulae into a Node (even though I don't understand it, LOL). For those Noobs like me the second image explains it so now I understand. Thanks Edited September 11, 2016 by Alan Woodwell Add image Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.