FB CAD

User projects written in or related to FreeBASIC.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Postby owen » Jul 22, 2008 9:15

when i plot my ellipse is use the followning for x,y (a point on the ellipse)
eplotx=Cos(eend*pi/180)*er1*Cos(eangle*pi/180) - Sin(eend*pi/180)*er2*Sin(eangle*pi/180)+ex1
eploty=Sin(eend*pi/180)*er2*Cos(eangle*pi/180) + Cos(eend*pi/180)*er1*Sin(eangle*pi/180)+ey1
eplotx and eploty are a point on the ellipse
eend is an angle from 0 to 360
eangle is the ellipses rotation
er1 is either the major or minor axis
er2 is the other axis
ex1 and ey1 are the center of the ellipse

now i thought that knowing the values of all variables except for one of the axis would be my final sollution and it would be just a simple matter of a little algerbra to solve for the unknown variable (er1 or er2)

for exampe solving for er2
we start with:
eplotx=Cos(eend*pi/180)*er1*Cos(eangle*pi/180) - Sin(eend*pi/180)*er2*Sin(eangle*pi/180)+ex1

and slove for er2:
er2=Cos(eend*pi/180)*er1*Cos(eangle*pi/180)+ex1-eplotx/Sin(eend*pi/180)*Sin(eangle*pi/180)

but it's not working
maybe it's my algerbra

ps. thanx for helping.
once i get this figured out i can add a few more features to progy such as snap to tangent, chamfer and fillet.

the idea of calculating two tangents to an ellipse:
it all came about cuz my friend was asking me to add dimensions which i did (kinda) until i ran it the problem of adding text. i then realized that text was an issue because nobody has a progy that will convert various fonts into dxf files that uses ARCS as well as lines to trace out the characters. so in short, not only will two tangents to an ellipse serve for the purpose of fillet but it will also help me finally trace out fonts (characters), calculating the curves in hand writing as well. actually, elliptacal curves may not address all curves in hand writing BUT for the purpose of creating a dxf file for each charater in multiple fonts i think it'll do.
Last edited by owen on Jul 22, 2008 10:19, edited 1 time in total.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

bfuller u did it

Postby owen » Jul 22, 2008 9:31

thx bfuller, u did it. i can see the effect of changeingthe slope of the second line, how it affects the ellipse center as well as the second axis.
if this aint it, it's got to be close.
thx
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

splines

Postby owen » Jul 22, 2008 9:45

calstover, thx for the encouragment. it has been about a year since i worked on the program.
splines are in my wish list and i kinda been putting them on the back burner as they seem to be quite complex. you make it sound as if they might be simpler. i thank you for the references to cubic math. i'm sure it will serve handy when i get to them.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

fb cad seven

Postby owen » Jul 22, 2008 9:57

i saved the bas and exe on the server
take a peek if u like to see a bit of the diminsion and fillet functions
also when creating an ellipse you'll see i added the foci (probably make that a feature of the ellipse ie. snap to foci or something)
http://fbcadcam.org/files/fbcad7.bas
http://fbcadcam.org/files/fbcad7.exe

this equation below is what i was looking for: (not in fbcad7 yet)
radius=(fxm-x1)/Cos(ASin((y1-fym)/(y1-curvexy(1,2))))

with the help from bfuller i was able to calculate the second axis (radius).
i havent tested in all quadrants yet but i believe it is the solution.
i'll post it in fbcad8 in a Few weeks.
thx again to all.
owen
Last edited by owen on Aug 01, 2013 19:12, edited 1 time in total.
MystikShadows
Posts: 596
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:

Postby MystikShadows » Jul 22, 2008 17:00

the link to the fbcad7.bas file doesn't seem to work by the way. :)...I really still like where FBCad is going owen, really excellent work.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

some progress

Postby owen » Aug 23, 2008 3:20

http://fbcadcam.org/files/fbcad8.bas

http://fbcadcam.org/files/fbcad8.exe

draw a horizontal line (from left to right
then draw a vertical line from bottom up (draw this line to the right and below the first line)

click F for fillet

click the first line (the end point on the right side of the line - use snap)
then move the mouse down and over to the right
and then over the second line

see example avi file
http://fbcadcam.org/vids/fbcad8.avi
for some reason i can't down load the avi file with ie but it down loads using firefox

this is cool, it works even if the first line is not at 0 degrees.
had to do a bit of rotate / translate / the rotate back again to get it done.

next, i got to work on the exception of the position of the second line in the 2nd and 3rd quadrants (ie. the second line is up above the first line)
Last edited by owen on Aug 01, 2013 19:59, edited 2 times in total.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

elliptical arc tangent to two lines

Postby owen » Sep 01, 2008 3:29

ok fbcad9 has the 4 quadrants solved
fbcadcam.org/files/fbcad9.exe
fbcadcam.org/files/fbcad9.bas
fbcadcam.org/files/eatttl.avi
Last edited by owen on Aug 01, 2013 19:14, edited 1 time in total.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

8 worked 9 has problem

Postby owen » Sep 03, 2008 5:18

in version 8 the math is working but in 9 there is an error in the calculation of the angle. (this happened while trying to solve for the 4 quadrants). i'll find the error and post it in 10
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

creating elliptical arcs

Postby owen » Sep 03, 2008 14:28

in version 10 using the fillet feature
this helps draw a curve between two lines so that the cuve smoothly flows from one line to another. the cuve created is an elliptical arc that both lines will be tangent to.

fbcadcam.org/files/fbcad10.exe
fbcadcam.org/files/fbcad10.bas
Last edited by owen on Aug 01, 2013 19:14, edited 1 time in total.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

first character set

Postby owen » Sep 06, 2008 14:41

you can download the DXF files of the characters A - Z and 0 - 9
note: i only did uppercase A - Z no lower case yet.
links are:
http://fbcadcam.org/files/owen/A.dxf
http://fbcadcam.org/files/B.dxf
http://fbcadcam.org/files/C.dxf
...
http://fbcadcam.org/files/Z.dxf
and
http://fbcadcam.org/files/0.dxf
thru
http://fbcadcam.org/files/9.dxf

here's the zip file http://fbcadcam.org/files/A-Z_0-9.zip

i manually traced out the alpha numeric characters.
this is why i was working on the elliptical arc Tangent to Two lines function.

i hope to use this math in order to programmatically trace out the various fonts a user has on their system but that's going to take some doing.
Last edited by owen on Aug 01, 2013 19:16, edited 1 time in total.
Sslaxx
Posts: 107
Joined: Aug 31, 2008 16:53
Location: Malvern, Worcs, UK
Contact:

Hmmm. Compilation errors.

Postby Sslaxx » Sep 06, 2008 15:13

Just so you know. Linux SVN FreeBASIC (as of today).

Using just plain fb:
fbc wrote:fbcad4.bas(1) error 135: Only valid in -lang deprecated or fblite or qb, found 'Option' in 'Option Explicit'
fbcad4.bas(65) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ',' in 'Declare Sub panpointtomouse(x,y)'
fbcad4.bas(71) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ')' in 'Declare Sub submenuitem(j)'
fbcad4.bas(93) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ',' in 'declare function getbuttonid(x,y) as Integer'
fbcad4.bas(151) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ',' in 'Dim Shared drawareax1,drawareay1,drawareax2,drawareay2'
fbcad4.bas(186) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ',' in 'function getbuttonid(x,y) as integer'
fbcad4.bas(2327) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ')' in 'sub createnewmodcircles(j)'
fbcad4.bas(3366) warning 13(0): Missing closing quote in literal string
fbcad4.bas(3992) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ',' in 'Sub panpointtomouse(x,y)'
fbcad4.bas(4171) warning 13(0): Missing closing quote in literal string
fbcad4.bas(5348) error 136: Default types or suffixes are only valid in -lang deprecated or fblite or qb, found ')' in 'Sub submenuitem(j)'
fbcad4.bas(6581) warning 13(0): Missing closing quote in literal string


Using -lang fblite
fbc -lang fblite wrote:fbcad4.bas(3241) error 4: Duplicated definition, erot
Dim As Double erot,cr1,cr2
^
fbcad4.bas(3366) warning 13(0): Missing closing quote in literal string
fbcad4.bas(4171) warning 13(0): Missing closing quote in literal string
fbcad4.bas(6581) warning 13(0): Missing closing quote in literal string


Commenting out the duplicated definition line appears to make it compile. "-lang deprecated" works with the warnings; no errors are given.

The lines in question:
fbcad4.bas(3366) wrote: Case "circle

fbcad4.bas(4171) wrote: itemstring="ELLIPSE

fbcad4.bas(6581) wrote:Data "-Save & EXIT


Seems to work OK otherwise, if flickery. "Save as" appears not to be working however.
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

fbcad versions

Postby owen » Sep 06, 2008 16:22

sorry for the confussion. i didn't have the index page on htwif up to date. the latest version is number 10.
i just updated the index page to link to fbcad10.bas and exe.
http://fbcadcam.org/files/fbcad10.bas and http://fbcadcam.org/files/fbcad10.exe

as far as the errors while compiling any version of fbcad...
i use an older version of fbc version 0.16.

not everything in fbcad works yet such as most of the MENU items. Open and Save work. also some of the buttons on the left do not work yet such as chamfer.

this code is so sloppy, frankly it needs to be re-written and several features are either not coded yet or need work.

i don't plan on doing a re-write any time soon because i have so much concept work to do still that it's pointless to begin a re-write.

for example, i'm working on font's at the moment so that i can finish my dimension feature. naturally i will need to add a scale feature in order to handle fonts appropriately.

it's like a never ending thing which is why this cad project is so fun to me.

and remember, this whole project was initially to make a freebasic cad proggy for the comunity as well as a way to show other how to program. at the moment, it serves as a good example of what not to do.

thnx for your intersts. perhaps one of these days i will entertain the idea of paying some programmers to help me complete this entire project, actually, endless project.
cheers, owen
Last edited by owen on Aug 01, 2013 19:17, edited 1 time in total.
Sslaxx
Posts: 107
Joined: Aug 31, 2008 16:53
Location: Malvern, Worcs, UK
Contact:

*nods*

Postby Sslaxx » Sep 06, 2008 16:32

I'm not sure if fbc 0.16 reports these, but you're still getting warnings about missing quotes. Beyond these, the code compiles using "-lang deprecated".

fbc wrote:Documents/fbcad10.bas(3655) warning 13(0): Missing closing quote in literal string
Documents/fbcad10.bas(4461) warning 13(0): Missing closing quote in literal string
Documents/fbcad10.bas(7209) warning 13(0): Missing closing quote in literal string


I've uploaded a version with these warnings corrected.

http://sslaxx.twu.net/fbcad10.bas
owen
Posts: 432
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

fbcad10 update

Postby owen » Sep 06, 2008 18:48

Sslaxx
thanx for making the corrections of missing quotation marks. i saved your copy of fbcad10 on htwif as well as my working copy on my system so now all subsequent versions will not have those errors in it.
counting_pine
Site Admin
Posts: 5793
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Sep 06, 2008 22:49

If you put '$lang: "deprecated" at the top of your code, e.g.

Code: Select all

'$lang: "deprecated"
Option Explicit
...

Then it should work without command-line arguments in the latest version of FB, while having no effect on its compatibility with older versions.

With the erot "duplicated definition" error, I couldn't see what the best fix would be. But basically it happens because you use one version of it, and then you dim another version to use later, in an inner scope. Lang deprecated allows that, but lang fblite doesn't.

One way to fix it would be to rename erot in that inner scope to something else, e.g. erot2.
A better fix *might* be to just not dim erot there, and use the variable that already exists with that name. But that depends on whether the old copy of erot is still being used for something else.

Either way, you probably didn't intend for two versions of erot to coexist, so the error that lang fblite picks up could be seen as a polite way of pointing out what you've done. If you fix it, then your code should hopefully work in the latest version, in either lang fblite or lang deprecated.

Obviously, we'd like to encourage people to upgrade to the latest version of FB, whether they're using the default "-lang fb" dialect or not. Hopefully, the transition for your code looks like it should be relatively painless.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest