redo fbcad / cam / 3d as a community project.

and as b4 just for the fun of it.

creativity is keen.

400 usd $ per month split amongst top contributors.

let's see how much we can accomplish in one year's time.

funds provided by owen and other like minded philanthropists.

opreese@gmail

4076558537

## fbcadcam redo

### Re: fbcadcam redo

viewtopic.php?f=8&t=7441

fb cad was writen by me, inspired by the late dennis waites out of johannesburg south africa, a brilliant engineer and great friend.

fb cad was writen by me, inspired by the late dennis waites out of johannesburg south africa, a brilliant engineer and great friend.

### Re: fbcadcam redo

last version was 0.1.33.31

http://fbcadcam.org/files/fb2dcadcam1-33-31.zip

http://fbcadcam.org/files/fb2dcadcam1-33-31.zip

Last edited by owen on Aug 01, 2013 16:37, edited 2 times in total.

### Re: fbcadcam redo

Hello Owen,

I used to hang around this forum a while back, and contribute every now and then (in the "squares" thread etc--hello to Richard and Albert and Dodicat et al---I still "lurk", and the hardware area), but I bought a sailboat and rapidly came to realise that sailing was more fun than programming----mind you, the forums have their equivalent proportion of quirky souls---not sure which is worse LOL.

Anyway, if you have any difficult geometry type problems you want solved, post them and I will put the thinking cap on. No guarantees, and I am not a good programmer really, maybe not even average, but I do like to think that I am a good problem solver and have a good mathematical mind so can perhaps get some algorithms sorted if necessary. Pen and paper first, then write the code to replicate is my tactic. Don't ask me about 3D matrix manipulation though, I never did come to grips with dot and cross products and all that jargon-too old a dog now to teach new tricks! I did use your FBCAD program a few times, and then got interested in CAM, even bought a little 3D milling machine too but it spends more time gathering dust than actually milling anything. My ambitions were not matched by available spare time!!

I used to hang around this forum a while back, and contribute every now and then (in the "squares" thread etc--hello to Richard and Albert and Dodicat et al---I still "lurk", and the hardware area), but I bought a sailboat and rapidly came to realise that sailing was more fun than programming----mind you, the forums have their equivalent proportion of quirky souls---not sure which is worse LOL.

Anyway, if you have any difficult geometry type problems you want solved, post them and I will put the thinking cap on. No guarantees, and I am not a good programmer really, maybe not even average, but I do like to think that I am a good problem solver and have a good mathematical mind so can perhaps get some algorithms sorted if necessary. Pen and paper first, then write the code to replicate is my tactic. Don't ask me about 3D matrix manipulation though, I never did come to grips with dot and cross products and all that jargon-too old a dog now to teach new tricks! I did use your FBCAD program a few times, and then got interested in CAM, even bought a little 3D milling machine too but it spends more time gathering dust than actually milling anything. My ambitions were not matched by available spare time!!

### Re: fbcadcam redo

i have two fun algos to work on that could be incuded in the redo.

for the cam functionality a lawn mower algo is needed. given an area of random shape plot an efficient path. i.e. derive the lawn mowers path based on a given perimeter. used in milling out or cutting away excess material. note, ive never ran a cnc machine, its just what i would imagine would be needed in the cam software.

second algo is a rectangle in a rectangle problem. is used for structural integrity. given the height and width of rectange A and only the height of rectangle B solve for rectangle B width. rectangle B is encompassed by A such that B serves as a cross support member for A. i.e. a section of a wooden fence has a 2x4 nailed at the top left and bottom right to add rigidity. the fence is 6 x8 feet and is rectangle A the 2x4 is rectangleB. 4inches is height solve for width or length. requirement rectangle B all 4 corners contact the sides of rectangle A. hint rectangle B width is also radius of circle in which rectangle B height is a cord of that circle which starts and ends where circle intersects rectangle A.

for the cam functionality a lawn mower algo is needed. given an area of random shape plot an efficient path. i.e. derive the lawn mowers path based on a given perimeter. used in milling out or cutting away excess material. note, ive never ran a cnc machine, its just what i would imagine would be needed in the cam software.

second algo is a rectangle in a rectangle problem. is used for structural integrity. given the height and width of rectange A and only the height of rectangle B solve for rectangle B width. rectangle B is encompassed by A such that B serves as a cross support member for A. i.e. a section of a wooden fence has a 2x4 nailed at the top left and bottom right to add rigidity. the fence is 6 x8 feet and is rectangle A the 2x4 is rectangleB. 4inches is height solve for width or length. requirement rectangle B all 4 corners contact the sides of rectangle A. hint rectangle B width is also radius of circle in which rectangle B height is a cord of that circle which starts and ends where circle intersects rectangle A.

### Re: fbcadcam redo

bfuller, i think u might be the first person to mention actually using fbcad. that's pretty cool to hear. thanx for offering geometry help.

### Re: fbcadcam redo

Owen,

Thanks for responding. It's friday night in Oz. Nice glass of wine in one hand, Galaxy phone in the other, reading FB Forum

CNC is really cool, simple but powerful. I wish I had more time to spend on it.

Re lawnmower, from what I have seen so far, they effectively just use a raster scan in milling software. Nothing sophisticated.

The rectangle in a rectangle challenge will require me to get the pencil out Ha Ha.

Thanks for responding. It's friday night in Oz. Nice glass of wine in one hand, Galaxy phone in the other, reading FB Forum

CNC is really cool, simple but powerful. I wish I had more time to spend on it.

Re lawnmower, from what I have seen so far, they effectively just use a raster scan in milling software. Nothing sophisticated.

The rectangle in a rectangle challenge will require me to get the pencil out Ha Ha.

### Re: fbcadcam redo

So you've got a boat Bfuller.

Any intention of coming back round to Hadrian's Wall?

Might be several Friday nights in the passage.

Yes, the rectangle inside rectangle is not so easy.

Any intention of coming back round to Hadrian's Wall?

Might be several Friday nights in the passage.

Yes, the rectangle inside rectangle is not so easy.

### Re: fbcadcam redo

oops my hint was incorrect. the radius of circle is distance from center of rectangles to a corner of rectange B.

second hint. both rectangles share same center point.

hint is a poor choice of wording. observation is better.

note i only have an apx estimation idea of solving and is a method rather then equation.

second hint. both rectangles share same center point.

hint is a poor choice of wording. observation is better.

note i only have an apx estimation idea of solving and is a method rather then equation.

### Re: fbcadcam redo

Just as a quickie, I've iterated out using vectors.

The big rectangle is the screen, the leg of the small rectangle heads towards the bottom right corner where, upon arrival, it is duly tweaked.

The big rectangle is the screen, the leg of the small rectangle heads towards the bottom right corner where, upon arrival, it is duly tweaked.

Code: Select all

Type V2D

As Single x,y

End Type

#define vct Type<V2D>

Operator + (v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x+v2.x,v1.y+v2.y)

End Operator

Operator -(v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x-v2.x,v1.y-v2.y)

End Operator

Operator * (f As Single,v1 As V2D) As V2D 'scalar*V2D

Return vct(f*v1.x,f*v1.y)

End Operator

Function length(v As V2D) As Single

Return Sqr(v.x*v.x+v.y*v.y)

End Function

Function normalize(v As V2D) As V2D

Dim n As Single=length(v)

If n=0 Then n=1e-20

Return vct(v.x/n,v.y/n)

End Function

Dim As Integer xres,yres

'====================================================

'INPUTS

Dim As Single SmallRectangleHeight=200

Dim As Single BigRectangleWidth=800

Dim As Single BigRectangleHeight=400

'=================================================

Screenres BigRectangleWidth,BigRectangleHeight

Screeninfo xres,yres

Dim As V2D ctr=vct(xres/2,yres/2)

Dim As Single dy,ds,diffx,diffy

Dim As V2D start,norm,temp,temp2,temp3

Dim As Integer flag

Do

Screenlock

Cls

ds=ds+.001

start=vct(0,yres-dy)-ctr

norm=vct(-start.y,start.x)

norm=.5*SmallRectangleHeight*normalize(norm)

temp=ctr+ds*start

temp2=temp+norm

temp3=temp-norm

Line(temp3.x,temp3.y)-(temp2.x,temp2.y)

circle(temp3.x,temp3.y),5,,,,,f

circle(temp2.x,temp2.y),5,,,,,f

If temp3.y>=yres Then

If temp2.x>0 Then

dy=dy+1

End If

If temp2.x<=0 Then

diffy=yres-temp2.y:diffx= temp3.x

Line(xres-diffx,0)-(xres,diffy)

Line(temp3.x,yres)-(xres,diffy)

Line(xres-diffx,0)-(temp2.x,temp2.y)

Screenunlock: Beep:Exit Do

End If

End If

Screenunlock

Sleep 1,1

If Len(Inkey) Then flag=1: Exit Do

Loop

If flag=0 Then

Print "Length of inside rectangle = ";length(vct(temp3.x,yres)-vct(xres,diffy))

Print "Height of inside rectangle = ";SmallRectangleHeight

Else

Print "Exit"

End If

Sleep

### Re: fbcadcam redo

I think with rectangle inside rectangle there are an infinite number of orientations.

Just as a rectangle inside a circle.

So there would be no unique analytical solution.

Here's a slightly different approach:

Just as a rectangle inside a circle.

So there would be no unique analytical solution.

Here's a slightly different approach:

Code: Select all

'beeper

extern "windows" lib "user32"

declare function _Beep alias "MessageBeep" (byval as integer) as integer

end extern

Type V2D

As Single x,y

End Type

#define vct Type<V2D>

Function Rotate2D(pivot As V2d,p As V2d,a As Single) As V2D

var rotx=(Cos(a*.0174533)*(p.x-pivot.x)-Sin(a*.0174533)*(p.y-pivot.y))+pivot.x

var roty=(Sin(a*.0174533)*(p.x-pivot.x)+Cos(a*.0174533)*(p.y-pivot.y))+pivot.y

Return vct(rotx,roty)

End Function

Operator + (v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x+v2.x,v1.y+v2.y)

End Operator

Operator -(v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x-v2.x,v1.y-v2.y)

End Operator

Operator * (f As Single,v1 As V2D) As V2D 'scalar*V2D

Return vct(f*v1.x,f*v1.y)

End Operator

Function length(v As V2D) As Single

Return Sqr(v.x*v.x+v.y*v.y)

End Function

Function normalize(v As V2D) As V2D

Dim n As Single=length(v)

If n=0 Then n=1e-20

Return vct(v.x/n,v.y/n)

End Function

Dim As Integer xres,yres

'====================================================

'INPUTS

Dim As Single SmallRectangleHeight=200

Dim As Single BigRectangleWidth=800

Dim As Single BigRectangleHeight=600

Dim As Single rotateangle=.2 'degrees(tweakable)

'=================================================

If BigRectangleHeight>BigRectangleWidth Then Swap BigRectangleHeight,BigRectangleWidth

Screenres BigRectangleWidth,BigRectangleHeight

Screeninfo xres,yres

Dim As V2D ctr=vct(xres/2,yres/2)'screen centre and centres of rectangles

Dim As Single ds,diffx,diffy

Dim As V2D start,norm,temp,temp2,temp3

Dim As Integer flag

start=vct(0,yres)-ctr

Do

Screenlock

Cls

ds=ds+.001 'motion increments

norm=vct(-start.y,start.x) 'get the normal vector to the direction of travel

norm=.5*SmallRectangleHeight*normalize(norm)'make the normal vector size= .5*SmallRectangleHeight

temp=ctr+ds*start 'move the SmallRectangle edge onwards

temp2=temp+norm 'top point

temp3=temp-norm 'bottom point

Line(temp3.x,temp3.y)-(temp2.x,temp2.y)'join top to bottom points

Circle(temp2.x,temp2.y),3,4,,,,f 'then circle them

Circle(temp3.x,temp3.y),3,4,,,,f

'Finishing condition

If temp2.x<=0 Then 'if top point is on the big rectangle(side) i.e done

diffy=yres-temp2.y:diffx= temp3.x

'join all the small rectangle corners

Line(xres-diffx,0)-(xres,diffy)

Line(temp3.x,yres)-(xres,diffy)

Line(xres-diffx,0)-(temp2.x,temp2.y)

Screenunlock:_Beep(-1):Exit Do

End If

If temp3.y>=yres Then 'if bottom point is on the big rectangle (base)

If temp2.x>0 Then 'if top point is still in the big rectangle (screen)

start=rotate2D(ctr,start,rotateangle)'lift the bottom point up a bit

'and continue the motion

End If

End If

Screenunlock

Sleep 1,1

If Len(Inkey) Then flag=1: Exit Do

Loop

If flag=0 Then

Print "Length of inside rectangle = ";length(vct(temp3.x,yres)-vct(xres,diffy))

Print "Height of inside rectangle = ";length(temp2-temp3)

Else

Print "Exit"

End If

Sleep

### Re: fbcadcam redo

dodicat presents a solution similar to how this is accomplished naturally. in other words, place the 2x4 on the bottom edge and slide it left till it butts up with the left side, doing this while maintaining a normal to the larger rectangles center. How dodicat calclates the norm is kinda hard for me to grasp. If someone can explain the math in his normalize function I would greatly appriciate it.

are there any other ways to do this?

are there any other ways to do this?

Last edited by owen on Aug 01, 2013 11:37, edited 1 time in total.

### Re: fbcadcam redo

In the images below, the two purple circles define the limits or ranges possible for the inscribed rectangle.

The red circle (within the range) has a chord of 39.18.

By adjusting the red circles radius from max to min while calculating the chords length could be another approach.

http://fbcadcam.org/pics/rectrect/rectrect1.jpg

http://fbcadcam.org/pics/rectrect/rectrect2.jpg

I wonder if there is a way to figure this out based on the ratio (h/w) of the rectangle?

http://fbcadcam.org/pics/rectrect/rectrect3.jpg

The red circle (within the range) has a chord of 39.18.

By adjusting the red circles radius from max to min while calculating the chords length could be another approach.

http://fbcadcam.org/pics/rectrect/rectrect1.jpg

http://fbcadcam.org/pics/rectrect/rectrect2.jpg

I wonder if there is a way to figure this out based on the ratio (h/w) of the rectangle?

http://fbcadcam.org/pics/rectrect/rectrect3.jpg

Last edited by owen on Aug 01, 2013 14:11, edited 1 time in total.

### Re: fbcadcam redo

i registered fbcadcam.com.net.org

hosting on bluehost.

will be transferring all files to the org.

will update refs links in forum to new url .

after looking at my files i realized 1.33.31 was my latest work not 1.33.19. what i did between 19 and 31 i dont recall at the moment.

http://fbcadcam.org/files/fb2dcadcam1-33-31.zip

hosting on bluehost.

will be transferring all files to the org.

will update refs links in forum to new url .

after looking at my files i realized 1.33.31 was my latest work not 1.33.19. what i did between 19 and 31 i dont recall at the moment.

http://fbcadcam.org/files/fb2dcadcam1-33-31.zip

### Re: fbcadcam redo

I added to dodicat's first code example illustrating how in fact he is maintaining a norm to the large rectangle's center.

still trying to figure out how does it though.

still trying to figure out how does it though.

Code: Select all

Type V2D

As Single x,y

End Type

#define vct Type<V2D>

Operator + (v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x+v2.x,v1.y+v2.y)

End Operator

Operator -(v1 As V2D,v2 As V2D) As V2D

Return vct(v1.x-v2.x,v1.y-v2.y)

End Operator

Operator * (f As Single,v1 As V2D) As V2D 'scalar*V2D

Return vct(f*v1.x,f*v1.y)

End Operator

Function length(v As V2D) As Single

Return Sqr(v.x*v.x+v.y*v.y)

End Function

Function normalize(v As V2D) As V2D

Dim n As Single=length(v)

If n=0 Then n=1e-20

Return vct(v.x/n,v.y/n)

End Function

Dim As Integer xres,yres

'====================================================

'INPUTS

Dim As Single SmallRectangleHeight=200

Dim As Single BigRectangleWidth=800

Dim As Single BigRectangleHeight=300

'=================================================

Screenres BigRectangleWidth,BigRectangleHeight

Screeninfo xres,yres

Dim As V2D ctr=vct(xres/2,yres/2)

Dim As Single dy,ds,diffx,diffy

Dim As V2D start,norm,temp,temp2,temp3

Dim As Integer flag

Do

Screenlock

Cls

Print "ctr=";ctr.x,ctr.y

ds=ds+.001

start=vct(0,yres-dy)-ctr

Print "start=";start.x,start.y

norm=vct(-start.y,start.x)

Print "norm=";norm.x,norm.y

norm=.5*SmallRectangleHeight*normalize(norm)

Print "norm=";norm.x,norm.y

temp=ctr+ds*start

Print "temp=";temp.x,temp.y

temp2=temp+norm

temp3=temp-norm

Line(temp3.x,temp3.y)-(temp2.x,temp2.y)

Line(temp3.x,temp3.y)-(ctr.x,ctr.y)

Print Sqr((ctr.x-temp3.x)^2+(ctr.y-temp3.y)^2)

Line(temp2.x,temp2.y)-(ctr.x,ctr.y)

Print Sqr((ctr.x-temp2.x)^2+(ctr.y-temp2.y)^2)

Line(temp2.x+(temp3.x-temp2.x)/2,temp2.y+(temp3.y-temp2.y)/2)-(ctr.x,ctr.y)

Print Sqr((ctr.x-(temp2.x+(temp3.x-temp2.x)/2))^2+(ctr.y-(temp2.y+(temp3.y-temp2.y)/2))^2)

Circle(ctr.x,ctr.y),Sqr((ctr.x-temp3.x)^2+(ctr.y-temp3.y)^2)

circle(temp3.x,temp3.y),5,,,,,f

circle(temp2.x,temp2.y),5,,,,,f

'diffy=yres-temp2.y:diffx= temp3.x

'Line(xres-diffx,0)-(xres,diffy)

'Line(temp3.x,yres)-(xres,diffy)

'Line(xres-diffx,0)-(temp2.x,temp2.y)

If temp3.y>=yres Then

If temp2.x>0 Then

dy=dy+1

End If

If temp2.x<=0 Then

diffy=yres-temp2.y:diffx= temp3.x

Line(xres-diffx,0)-(xres,diffy)

Line(temp3.x,yres)-(xres,diffy)

Line(xres-diffx,0)-(temp2.x,temp2.y)

Screenunlock: Beep:Exit Do

End If

End If

Screenunlock

Sleep 50,1

If Len(Inkey) Then flag=1: Exit Do

Loop

If flag=0 Then

Print "Length of inside rectangle = ";length(vct(temp3.x,yres)-vct(xres,diffy))

Print "Height of inside rectangle = ";SmallRectangleHeight

Else

Print "Exit"

End If

Sleep

Return to “Community Discussion”

### Who is online

Users browsing this forum: No registered users and 1 guest