I was drawing with AutoCAD and wrote a lisp-script for that I just recently switched to Sketchup. But I read your posts from 2009 and I was working very hard to translate it from lisp to ruby a few weeks ago. By the way, you are one of the developers I was adressing, because I love your CleanUp Plugin, that's one of the reasons I switched from AutoCAD to Sketchup, because skilled developers do things like that. Maybe you can use my codes to program a nice plugin. Or if anyone has some Ideas, I would be glad to help with the math
Posts made by vitaleMarco
-
RE: Catenary curve
-
RE: Catenary curve
Yes that's exactly what I was trying to do. that wiretool is great.
Thanks for that, but anyway my code is online, so if somebody wants to play around with this feel free to do so.
Marco
-
RE: Code to calculate Catenary curves?
Check out this port, this might help you.
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=64842
All the best Marco
-
Catenary curve
Hi this is my second post in this Forum, so forgive me for any mistake I do in this post, but I have some code I want to share with you.
As I posted before, I'm not the big ruby-developer and I honestly am not an UI-designer, but I know my math and did some calculations for catenary curves. I thought here in this Forum are a lot of great developers, who might be interested in my code and have the ability to use it for their plugin, so Sketchup-Users can profit from it.
The catenary curve is basically a part of a hyperbola and represents the curve of a rope or chain between two poles, this code draws a catenary curve by the given height of the left pole (height_1), the height of the right pole (height_2), the distance between the poles (catenary_distance), length of the "rope" (catenary_length) and the number of edges(stepCount).
The trick is to find the radius 'a' at the curve's minimum, which can only be determined by approximation:
catenary_a(catenary_length, h2, catenary_distance, initial)
this could also be done by using the newton raphson method, but in this case I think my function works very well.
Before we get to the code, here some backgroundinfo on the math. I created a graph on https://www.desmos.com/calculator/xdjl6lqo3b, which shows you the basic calculations and the resulting curves, you can play around with the variables to see what happens, so you don't have to rewrite the code everytime you change a parameter.
To draw the curve you just have to call this function:
drawCatenary(height_1, height_2, catenary_distance, catenary_length, stepCount)
but there are some conitions you should handle before you call the function:
**
- all the input-parameters are in [mm]
- the height of the right pole must be greater than 0 (height_2 > 0)
- the height of the right pole must be greater than 0 (height_2 > 0)
- the distance must be greater than 0 (catenary_distance > 0)
- the for the length of the rope (catenary_length) the following condition has to be true:
catenary_length > Math.sqrt((height_2 - height_1)**2 + catenary_distance**2)
- the stepCount(Number of edges) should be greater than 0 (stepcount > 0), to get an exact drawing it should be greater than 12**
Finally here is the code The Ruby Code for the Catenary Curve
I hope somebody with more programming skills, can use this to build a plugin. I also hope that you will test this code and reply for errors or mistakes, so I can fix them. For any questions on the code, please don't hesitate to ask.
Have fun with it
All the best Marco
-
Trajectory curve
Hi this is my first post in this Forum, so forgive me for any mistake I do in this post, but I have some code I want to share with you.
I'm not the big ruby-developer and I honestly am not an UI-designer, but I know my math and did some calculations for trajectory curves. I thought here in this Forum are a lot of great developers, who might be interested in my code and have the ability to use it for their plugin, so Sketchup-Users can profit from it.
The trajectory curve is basically a part of a negated parabola and represents the curve of a thrown object, this code draws a trajectory curve by a given distance, a throwangle(degrees), the startheight and the StepCount(number of edges).
Before we get to the code, here some backgroundinfo on the math. I created a graph on https://www.desmos.com/calculator/ceywkjp3nv, which shows you the basic calculations and the resulting curves, you can play around with the variables to see what happens, so you don't have to rewrite the code everytime you change a parameter.
To draw the curve you just have to call this function:
drawTrajectory(distance, angle, startheight, stepCount)
but there are some conitions you should handle before you call the function:
**
- All input-parameters are in [mm]
- the distance must be greater than 0 (distance > 0)
- the throwangle must be greater or equal to 0Β° and smaller than 90Β° (0 <= angle < 90)
- the height should be greater than 0 (safe)
It can also be smaller than 0, but then these following conditions have to be true:
trajectory_maxY(start_velocity(distance, degToRad(angle), startheight), degToRad(angle), startheight) >= 0
trajectory_maxX(start_velocity(distance, degToRad(angle), startheight), degToRad(angle)) <= distance
- the stepCount(Number of edges) should be greater than 0 (stepcount > 0), to get an exact drawing it should be greater than 12**
Finally here is the code Ruby code for the trajectory curve
I hope somebody with more programming skills, can use this to build a plugin. I also hope that you will test this code and reply for errors or mistakes, so I can fix them. For any questions on the code, please don't hesitate to ask.
Have fun with it
All the best Marco