|
-
Sep 7th, 2000, 02:44 PM
#1
Thread Starter
New Member
Does anyone know how to use complex numbers in visual basic? Or if it is possible to use them at all??
ie. What keyword do you use to signify i - the imaginary part?
Help would be greatly appreciated
Goat_Man
-
Sep 7th, 2000, 06:11 PM
#2
Fanatic Member
doubt it! but
Doubt it!
But tell me what you have in mind to do with complex numbers
(if you don't mind)
-
Sep 7th, 2000, 07:32 PM
#3
Thread Starter
New Member
Complex Numbers
To Lafor
I just wrote a simple program to draw a mandelbrot set and am just requiring the use of complex numbers to finish it. Unfortunetly the Mandelbrot set isnt going to work without the use of complex numbers! Oh well...
I thought VB would have utilised them seeing as they arent exactly ultra hardcore mathmatics or anything. But anyway...
-
Sep 7th, 2000, 09:11 PM
#4
Frenzied Member
Program complex arithmetic
You can program complex arithmetic. I suggest Functions for +, -, *, & / used with a Type defined as complex. Something like the following.
Code:
Public Type Complex
X As Double
Y As Double
End Type
Public Function Cproduct(A As Complex, B As Complex) _
As Complex
Dim Result As Complex
Result.X = A.X * B.X - A.Y * B.Y
Result.Y = A.X * B.Y + A.Y * B.X
Cproduct = Result
End Function
Public Function Csum(A As Complex, B As Complex) _
As Complex
Dim Result As Complex
Result.X = A.X + B.X
Result.Y = A.Y + B.Y
Csum = Result
End Function
Public Function Cquotient(A As Complex, B As Complex) _
As Complex
Dim Result As Complex
Dim R As Double
R = B.X * B.X + B.Y * B.Y
Result.X = (A.X * B.X + A.Y * B.Y) / R
Result.Y = (A.Y * B.X - A.X * B.Y) / R
Cquotient = Result
End Function
Use the above Functions as required to do your complex arithmetic. To avoid repetitive stress syndrome, you might want to use shorter names for the functions.
I did just a little checking of these functions, and am about 95% sure they are correct. It has been a lot of years since I did complex arithmetic, so perhaps you should verify my algebra.
Give me brief progress report when you get your project done.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Sep 10th, 2000, 05:55 AM
#5
Thread Starter
New Member
Complex Numbers
To Guv,
Thanks for that
The algebra was all correct and the program worked perfectly. It draws quite an interesting fractal as well. Thanks for your help
Dale
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|