CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > OpenSource CNC Design Center > Coding


Coding Post your Coding for opensource projects here.


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-26-2005, 05:51 PM
MetLHead's Avatar
Gold Member
 
Join Date: Mar 2003
Location: USA
Posts: 740
MetLHead is on a distinguished road
Open source geometry stuff

One of the biggest hurdles, I think, to writing any kind of CAD/CAM app is going to be getting a handle on the geometry involved. I'm going to contribute a Visual Basic module which contains 26 different geometry functions. This module contains only 2D functions, but could easily be adapted for 3D. I'm putting this up here so that hopefully someone will find it useful. If anyone wants to add to it or update it, that's great. Just make sure and re-post it here so that others can benefit too.

Scott
Attached Files
File Type: zip Geometry.zip‎ (5.7 KB, 610 views)
Reply With Quote

  #2   Ban this user!
Old 08-26-2005, 06:50 PM
Evodyne's Avatar  
Join Date: Dec 2004
Location: USA
Posts: 518
Evodyne is on a distinguished road

Scott,

Good Job! Thanks for the contribution. What have you done with this yourself?

Sincerely,

Lance/Evodyne
Reply With Quote

  #3  
Old 08-26-2005, 07:12 PM
MetLHead's Avatar
Gold Member
 
Join Date: Mar 2003
Location: USA
Posts: 740
MetLHead is on a distinguished road

This module is taken right out of NCPlot. Of course, NCPlot contains a lot more stuff... I can't give away everything!

Here's a good challenge that would be a great addition to an open source project:
Add cutter comp functions
Create pocketing routines

Okay, so that's two challenges, but I think both could be done using the building blocks provided by this module.

Scott
Reply With Quote

  #4   Ban this user!
Old 10-19-2007, 01:02 PM
Honges's Avatar  
Join Date: Oct 2007
Location: Germany
Posts: 1
Honges is on a distinguished road

Hi Scott,
thanks !!
These routines are exactly what I needed.
I had cold sweat running down my neck when thinking of reanimating my geometrical school knowledge :-)))
Best regards Honges
Reply With Quote

  #5   Ban this user!
Old 06-15-2010, 07:18 AM
 
Join Date: Feb 2010
Location: israel
Posts: 10
carbo20 is on a distinguished road

Thank you very much! it is very helpful library.
the only thing that i can't find anywhere is a function that receive 2 lines (2 points that defines each line) and a radius. the function returns the points of tangency.
it is for a fillet feature that I'm trying to build in vb.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-20-2010, 12:34 AM
 
Join Date: Aug 2007
Location: Argentina
Posts: 42
_Eduardo_ is on a distinguished road

Try something like this:

Notes:
- The endpoint of Line1 must be the startpoint of Line2. (<-- EDIT: Is not the same, it's the startpoint )

- The input is Line1,Line2 and Radius.R
- Return: Fill Radius with the rest of parameters (Radius.S,Radius.E,Radius.C,Radius.D)


(coypaste of the user types)
Code:
Type dPoint
    X As Double
    Y As Double
End Type

Type dLine
    S As dPoint         'Start Point
    E As dPoint         'End Point
End Type

Type dArc
    S As dPoint         'Arc Start Point
    E As dPoint         'Arc End Point
    C As dPoint         'Arc Center Point
    R As Double         'Arc Radius
    D As Integer        'Arc Direction (2=CW, 3=CCW)
End Type


Public Sub GetRadiusParms(Line1 As dLine, Line2 As dLine, Radius As dArc)
Dim D1u As dPoint
Dim D2u As dPoint
Dim rs As Double
Dim q As Double

    D1u.X = Line1.E.X - Line1.S.X
    D1u.Y = Line1.E.Y - Line1.S.Y
    q = Sqr(D1u.X ^ 2 + D1u.Y ^ 2)
    D1u.X = D1u.X / q
    D1u.Y = D1u.Y / q

    D2u.X = Line2.E.X - Line2.S.X
    D2u.Y = Line2.E.Y - Line2.S.Y
    q = Sqr(D2u.X ^ 2 + D2u.Y ^ 2)
    D2u.X = D2u.X / q
    D2u.Y = D2u.Y / q
    
    q = Radius.R * (D1u.X * D2u.Y - D1u.Y * D2u.X) / (1 + D1u.X * D2u.X + D1u.Y * D2u.Y)
    If q < 0 Then
        rs = -Radius.R
        Radius.D = 2
        q = -q
    Else
        rs = Radius.R
        Radius.D = 3
    End If
    
    Radius.S.X = Line1.E.X - q * D1u.X
    Radius.S.Y = Line1.E.Y - q * D1u.Y
    Radius.E.X = Line1.E.X + q * D2u.X
    Radius.E.Y = Line1.E.Y + q * D2u.Y
    
    Radius.C.X = Radius.S.X - rs * D1u.Y
    Radius.C.Y = Radius.S.Y + rs * D1u.X
                                      
End Sub
Sorry for the lack of comments

Good luck!

Last edited by _Eduardo_; 06-20-2010 at 10:11 AM.
Reply With Quote

  #7   Ban this user!
Old 06-20-2010, 02:02 AM
 
Join Date: Feb 2010
Location: israel
Posts: 10
carbo20 is on a distinguished road

Thank you very much.
I will try it.
Reply With Quote

  #8   Ban this user!
Old 07-07-2010, 04:44 AM
 
Join Date: Feb 2010
Location: israel
Posts: 10
carbo20 is on a distinguished road

It works!
Thank you.

I will explain my motivation:
I'm trying to draw the data from your code to the screen (and then to a file) .
I need to use only points (every 2 points i draw as a line on the screen - so i will be able to see what i am going to cut. my diamond turning cnc can only accepts points files).
I'm using the circle equation to find the z for each x (i'm using your points as start point for the fillet.
right now the only thing that works properly is your code
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 06:21 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361