Script for Curvature Calculation
 1-10  11-24

Previous
Next
 From:  Karsten (KMRQUS)
6634.11 In reply to 6634.10 
Hello Brian,

I'm happy to hear that the script is interesting for you and that you think it is worth, to invest your time to improve it:-)
About the factories You are completly right. May I have a look in your actual code to understand what you are doing now?
The problem with square and n-gons may caused by the straight lines. Straight lines leads to colinear sampling points. That leads to two problems. the bisection planes between them are parallel. The intersection line is a tangent to our known universe;-) The second problem is that the normal vector (Hesse Normal Form) will be created by the cross product from these colinear (parallel) vectors. The result is a Null-Vector (magnitude and all components are Zero). That leads to a singulary matrix. I tried to catch that in the script with:
if(DetA!=0)
{
sp.x=DetX/DetA;
sp.y=DetY/DetA;
sp.z=DetZ/DetA;
} else {
sp.x=p1.x;
sp.y=p1.y;
sp.z=p1.z;
}
return sp;

The problem is, that I tried to return a wrong centerpoint as a workaround for straight line sections in the curve. (Something shoud be returned:-()
Later the length for the curvature vector will be calculated. Normally the vector to the Radius is diffrent from zero. Because I return p1, in that situation it is zero - an so it's magnitude, and what have I done - shit:
var d_vec=moi.vectorMath.createPoint(ptx[n+1].x-cp.x,ptx[n+1].y-cp.y,ptx[n+1].z-cp.z);
var magn=magnitude(d_vec);
var sf=scalefactor*1000.0;
var sd_vec=moi.vectorMath.createPoint((d_vec.x*sf/(magn*magn)),(d_vec.y*sf/(magn*magn)),(d_vec.z*sf/(magn*magn)));

d_vec is zero -> magn is zero -> and then I made a divide by zero op - maybe that kills your script! But sometimes it works, I can't retrace the problem - maybe caused by floating point precision(Attachment). A quick and dirty workaround would be to add a small value to sp before returning. Better catch the divide by zero or catch the whole calculation of collinar points - I don't know which way is the best. (For a better understanding the expression (magn*magn): the first scales the vector to a normalized one (lenght 1) - the second magn scales it to the curvature.)

Would you post your file with the killer square? Then I can make some experiments at the weekend:-)

I hope my speculations are right!???

Kind regards
Karsten
Image Attachments:
Size: 158.2 KB, Downloaded: 124 times, Dimensions: 1366x768px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6634.12 In reply to 6634.11 
Hi Karsten

Most any square, or rectangle will do.
Here is a basic rounded square, which also does "assert failed."

I cannot comment on how or where to add exception handling for problems due to straight line segments,
because I have not studied the math (yet) :-)

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.13 In reply to 6634.12 
Hi Brian,

with rounded corners I get the message too. At the weekend I will try to fix it!

Greetings
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.14 In reply to 6634.12 
Hi Brian,

it seems that the DetA sometimes isn't zero for linesegments. So, caused by a division near zero, it produces very high values for the centerpoint. That crashes the factories, esspecially for interpcurve. I've try to fix it by limitation of a maximum radius of 10000 and a minimum radius for curvature calculation of 0.002 (csp returns for lines p1 - that leads to a radius of zero -> divide by zero - > high values for the factories). Further more the changes supresses the generation of degenerated lines (startpoint equals endpoint). I've marked the changes in the script with //############. Also I made some test with the results with another tool. You may have a look at the pictures. It seem that other tools seperates connected curves for the analyse. So the precission at the connection points, especially with lines, isn't good.

Have a nice day!

Kind regards
Karsten

EDITED: 22 Dec 2017 by KMRQUS

Attachments:

Image Attachments:
Size: 119.9 KB, Downloaded: 83 times, Dimensions: 815x814px
Size: 160.5 KB, Downloaded: 58 times, Dimensions: 617x904px
Size: 155.8 KB, Downloaded: 31 times, Dimensions: 617x904px
Size: 187.6 KB, Downloaded: 57 times, Dimensions: 876x722px
Size: 182.4 KB, Downloaded: 96 times, Dimensions: 876x722px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  bemfarmer
6634.15 
After many difficulties, I finally made a version using some htm code, which may be 10% faster.
It is not much of a speed up. It does show the ongoing point generation, and leaves the start point.
Some code was separated. Some code was moved to htm script.

I'm going to work on a helix script now.

- Brian

EDITED: 27 Apr 2014 by BEMFARMER


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Hamish Mead (HAIRYKIWI)
6634.16 
Hi Karsten,

Thanks for your script - and to Brian too for giving it a speed tweak.

The math of your script looks really interesting. Unfortunately, I don't have enough time right now to get back up to speed on matrices and work my way through your code. If you think the Gaussian elimination method for multiple linear equations would give a significant speed advantage over the Cramer method - and I can see how it might - then the following page offers a ready to use javascript function and may be worth a look:
http://martin-thoma.com/solving-linear-equations-with-gaussian-elimination/

When I ran your script run on the output from my NACA airfoil generating script, it looks very close to what Rhino's own curvature analysis was giving, (I originally started developing my script in RhinoPython). Sorry I don't have consistent screen captures of identical airfoil series to show from MoI and Rhino, but you get the idea:








Cheers,
Hamish

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.17 In reply to 6634.16 
Hi Hamish,

Thank You for the interessting link and I am glad to here, that the script is interessting for you.
yes, I think that a gaussian method could be faster, also for this small matricies. But, I have some Problems at the Moment: Frist - Time(as we all;-). The second enlarge the first Problem. The script has a serious design error, that kills also the performance. The function for calculating the centerpoints (csp) has 3 points as Parameters. So every call, biscectional planes were calculated - for the next call the second plane of the previous calculation is the first of the actual calculation. So I have a lot of redundant plane calcs. To improve the Performance a lot of changes have to be done.

Kind regards
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6634.18 
@ Karsten From the other thread! (where was the "ccc" );)
and this mysterious line (for me at first view)

<< The script without coloring and the node is in the extensions under infos. Insert the node, connect a curve to it and the out to an output. Press run - that's it.

A sort of miracle! :)



I have just a doubt in what folder put the ccc.js and ccc.html (so i put them both commands and nodes folders ! )

despit of that seems that's is working like a charm! :)

and damned I must translate an another node! :)

Edit: In fact a lot of !!! (all extentions' nodes that i have missed! Not only the "infos" but all the rest! :D

Here only the Infos/ "Curvature" French Translation is made!



PS That will be a task to find what was the start curve who give this last Blue/Red colorized drawing! ;)

In fact easy if you can zoom ! ;)

Just a question : why the curve selected dont stay drawn during the application of the Infos node ?



And does it normal that a simple circle gives an "open result" ? (same for the ellipse of the first image of this post)



An hard day comes with all that to translate! :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.19 In reply to 6634.18 
Hello Pilou,

the problem of the open analysis curve for closed curves is caused by the patharray factory. The script works with a startpoint of the curve, arrays it to the curve and calculates the center of an theoretical arc for 3 following points. For a closed curve the arrayfactory don't calculate the last point, because it's the same as the start point. It's possible to improve that, but for the analysis it has not an effect, because the start and end point would need a previous point and following point. I solved that with a lagrange interpolation. The old script don't calculates start and endpoint. Ccc has to be placed in the command folder. It is complete independent from the node stuff. It's older than the elephant. Please play with the number of sample points and rhe scale factor.

Have a nice day
Karsten

EDITED: 21 Dec 2017 by KMRQUS

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.20 In reply to 6634.19 
p. s. If you want to see also your curve in the nodeeditor while running a curvature analysis you can clone it first and give one clone to a second output node.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6634.21 In reply to 6634.20 
Thx for all these infos!
It's not precisely for me but for French people who will ask me that! :)

About the double curve by clone : very tricky simple!
I'm sorry I didn't find it all by myself!

Have happy Christmas...and coding!
See you the next year!
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
6634.22 
What is CCC ? Construction Curvature Calculation ?

Seems there is something! Like there is no title appropriated?

In English I have 2 Lines : (and not Select Curve(s) to Analyse! )
Choose Number
of Sample Points






Result!

EDITED: 21 Dec 2017 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Karsten (KMRQUS)
6634.23 In reply to 6634.22 
I saw a film, there was some saying : Give me names of wild animals! Answer: Evil butterfly!

My first mind was calculate curves curvature, but it's to long so CCC, but I can't speak french so it's up to you how you will translate it. The right name in english is comp curve, I think. I read also porcupine analysis, but I think it's for surfaces and also a word used by Dassault. I'm not shure if they can english really. Some other naming in CATIA was raising my doubts in the past;-) Anyway, In french most of the things sounds better and more graceful.

Have a nice day
Karsten
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Frenchy Pilou (PILOU)
6634.24 In reply to 6634.23 
No, my question was not about some names of things (except CCC) but just why that is writed inside the code is not shown on the panel !
Aespecially on the title!

I have offseted the text lines on the Nopad++ for have the right thing! :)

EDITED: 9 Jan 2018 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages:  1-10  11-24