User projects written in or related to FreeBASIC.
owen
Posts: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:
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
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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### bfuller u did it

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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### splines

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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

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)

this equation below is what i was looking for: (not in fbcad7 yet)

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.
Posts: 596
Joined: Jun 15, 2005 13:22
Location: Upstate NY
Contact:
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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### some progress

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
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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### elliptical arc tangent to two lines

Last edited by owen on Aug 01, 2013 19:14, edited 1 time in total.
owen
Posts: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### 8 worked 9 has problem

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: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### creating elliptical arcs

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.

Last edited by owen on Aug 01, 2013 19:14, edited 1 time in total.
owen
Posts: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

### first character set

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.
...
and
thru

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.

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:

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

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.

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*

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.

owen
Posts: 505
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

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
Posts: 6091
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs
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.