I have just finished writing my first program in Q basic.
I was dumbfounded that Q Basic does not allow trigonometrical functions that include inverse SIN (ASN)and COS,(ACS) yet allows inverse TAN (ATN). Not only that, it only gives trigonometrical results in RADIANS, not degrees. Whats the story here?
I acknowledge that I am only very new to this great programming medium and there is something I may have missed in the tutorials, but can someone point me in the right direction as to how I can include these functions in my programs, without having to convert degrees to radians.
Bill
Degrees in Qbasic
Moderators: Administrator, Global Moderator

 Global Moderator
 Posts: 95
 Joined: Tue Apr 30, 2002 1:38 am
 Location: Pennsylvania
 Contact:
Re: Degrees in Qbasic
There are functions SIN and COS and TAN in qbasic, both 4.5 and 7(PDS). To convert a radian value to degrees, multiply it by 180/PI. It is not uncommon practise to build a lookup table of Trig funtions to speed up their uses to accessing ram rather than actually calculating every time.

 QBasic God
 Posts: 166
 Joined: Tue Mar 25, 2003 12:45 am
 Location: U.S.A.
 Contact:
Also...
You might check out one of the libraries. I know that DirectQB has the DQBangle function. It's a binary shift function though, so you have to understand that you still have to do an extra calculation because
DQB's angles are in the range of 0255.
Angle%= Any angle from 0 to 359............
SendAngle%= INT(Angle% / 1.40625)
I don't know if this helps at all, but DQB was coded with ASM. It has sprite rotation and the works. I'd check into LIBS if I were you.
DQB's angles are in the range of 0255.
Angle%= Any angle from 0 to 359............
SendAngle%= INT(Angle% / 1.40625)
I don't know if this helps at all, but DQB was coded with ASM. It has sprite rotation and the works. I'd check into LIBS if I were you.
Come check out FreeBASIC. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!
Re: Degrees in Qbasic
Hi,
you can get the other functions from ATAN:
ACOS(x) = ATAN((sqrt(1x^2))/x)
and
ASIN(x) = ATAN(x/(sqrt(1x^2)))
But you need to do some fiddling about for when the denominators are zero.
Cheers,
Chris
you can get the other functions from ATAN:
ACOS(x) = ATAN((sqrt(1x^2))/x)
and
ASIN(x) = ATAN(x/(sqrt(1x^2)))
But you need to do some fiddling about for when the denominators are zero.
Cheers,
Chris
At the beginning of your program, define the conversion factors:
d2r = 3.14159/180 'd2r = degrees to radians
r2d = 180/3.14159 'r2d = radians to degrees
Then use the above factors as needed, for instance:
d2r = 3.14159/180 'd2r = degrees to radians
r2d = 180/3.14159 'r2d = radians to degrees
Then use the above factors as needed, for instance:
Code: Select all
PRINT " The value of sin(30) =";SIN(30*D2R)
PRINT " 30 degrees =";30*d2r;"radians, ";
PRINT "and 0.5 radians =";0.5*r2d;"degrees."
Re: Degrees in Qbasic
Anonymous wrote:I have just finished writing my first program in Q basic.
I was dumbfounded that Q Basic does not allow trigonometrical functions that include inverse SIN (ASN)and COS,(ACS) yet allows inverse TAN (ATN). Not only that, it only gives trigonometrical results in RADIANS, not degrees. Whats the story here?
I acknowledge that I am only very new to this great programming medium and there is something I may have missed in the tutorials, but can someone point me in the right direction as to how I can include these functions in my programs, without having to convert degrees to radians.
Bill
When BASIC was first devised by two university professors, they used radians functions, as this is the "normal" mode for mathematical functions, in general. And, only the four tringonometric functions, SIN, COS, TAN and ATN were included, the others being left for students to derive, I guess as a challenge.
When QB, QBasic, BASICA, QuickBASIC and, yes, even Visual Basic came along, these little unpleasantries were not corrected, and, so, we are stuck with this, at least for the foreseeable future.
The other arc, or "inverse" functions, ASIN and ACOS have already been posted by the other "Guest" (not me), and a method of converting radians to degrees, and viceversa also have been posted.
Finally, on could create the userdefined functions (UDF) for the various trigonemetric functions, for instance, one called SIND(angle in degrees), in which entering SIND(30) would be the equivalent of entering SIN(303.14159/180), and so on. Would that help you out, Guest No. 1? (the original poster, or OP, as "we" call them )
RalphA
Degrees in QuickBASIC
Sorry about the error above. Please change the "equivalcy" to:
SIND(30) = SIN(30*3.14159/180)
Thank you for your patience.
RalphA
SIND(30) = SIN(30*3.14159/180)
Thank you for your patience.
RalphA
Return to “QBasic / QuickBasic related”
Who is online
Users browsing this forum: No registered users and 1 guest