|
Hi
Just found some wonderful properties of number 4.
1. 4 is the only perfect square whose reciprocal is also a perfect square.
2. Any perfect square when devided by 4 gives a reminder of either 1 or 0.
Is this something already known?
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Zainu wrote: Is this something already known?
probably for a few hundred years.
|
|
|
|
|
Zainu wrote: Is this something already known?
Technically, yes, I'm fairly sure that it is known by at least one person. I'm sure others will claim knowledge of it, too. Whether they do or not, you'll never know for sure.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Zainu wrote: 4 is the only perfect square whose reciprocal is also a perfect square.
hence 1/4 is a perfect square while, for instance, 1/9 not?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Sounds like you are just discovering the magic of Number Theory, you can find lots of interesting resources on the web.
I'm not sure what you are implying with (1), but (2) is very well known. 0 and 1 are called the quadratic residues mod 4. Some other examples, the same thing is true mod 3, but in mod 8 the residues are 0,1,4.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
|
Mathworld is a great website, alot of good stuff there
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hiya guys.. Using C++ does anyone know how i can tell if a line is linear or not? I want the user to enter 5 readings which i can plot on a chart. However i would like a function to find out if the plotted line is linear.
Any help would be greatly appreciated!
|
|
|
|
|
EDIT: Not sure if this is needed or not: if the slope between x_1,y_1 and x_5,y_5 is greater than 1, swap the x and y values for each coordinate pair. This swap is needed to keep the delta value in the next step smaller than 1.
Create a function for the line y = f(x) using points 1 and 5. Then of each of the 3 points in the middle calculate f(x_n), if ABS(f(x_n) - y_n) < 1, then x_n,y_n is on on the line (give or take the rounding error from forcing integral values).
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
Hi Dan,
Same idea, but without any math showing, the lazy approach:
- Create a GraphicsPath
- add the line connecting the end points
- widen with a pen (I guess width=3, more gives more tolerance)
- check all points fall within (that's GraphicsPath.IsVisible)
|
|
|
|
|
Hiya Luc. Thanks also for your reply. This is an interesting approach here, however GraphicsPath is a .net class while i am using native C++/MFC.
|
|
|
|
|
Cheers Dan. This is great..
Im just a little confused about the functions f(x) and f(x_n). What is the body of these functions?
|
|
|
|
|
The same function, f(x) is the generic function, x_n is x_1, x_2,... (the x points of your test coordinates). Probably best done using the slope-intercept form. Google if you need help getting the values from two points.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
ahh-ahhh..... the penny has dropped. Thanks again.
|
|
|
|
|
Try to apply Linear Regression to your points.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi CPallini,
it depends on what the points represent:
- for ideal (x,y) points, yes
- for graphic approximation (such as Bresenham), not so good
Greetings
|
|
|
|
|
It appears to me like a mathematical problem rather than a (digital) graphics one. Anyway, only the OP can clarify the point (I hope!)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
hi flippydeflippydebop
"entering 5 readings" u mean input 5 values then in each reading u will get a point's value mean(x,y)
it means
int x[5], y[5]
for( i=0; i<5; i++ )
read x[i], y[i]
resultX = x[0] - x[1] - x[2] - x[3] - x[4]
resultY = y[0] - y[1] - y[2] - y[3] - y[4]
if( ( resultX == 0 ) and ( resultY == 0 ) )
print "line is linear"
else
print "line is not linear"
i think this is the solution if it is true plz inform me if it is wrong then also inform me plz..
in case it is true u can further enhance and can be maked easy and powerful then this.
plz inform me about its correctness
habib bhutto
|
|
|
|
|
hi flippydeflippydebop
"entering 5 readings" u mean input 5 values then in each reading u will get a point's value mean(x,y)
it means
int x[5], y[5]
for( i=0; i<5; i++ )
read x[i], y[i]
resultX = x[0] - x[1] - x[2] - x[3] - x[4]
resultY = y[0] - y[1] - y[2] - y[3] - y[4]
if( ( resultX == 0 ) and ( resultY == 0 ) )
print "line is linear"
else
print "line is not linear"
i think this is the solution if it is true plz inform me if it is wrong then also inform me plz..
in case it is true u can further enhance and can be maked easy and powerful then this.
plz inform me about its correctness
habib bhutto
|
|
|
|
|
won't work.
points 10,10 11,11 12,12 13,13 14,14. Obviously linear, but resultx and resulty are both -50.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
To understand if a line is 'approzimately' a line you can use the Hough transform .
Hope helps
Russell
|
|
|
|
|
|
You could use the equation of a line y=mx+c, we don't know the value of c (and we can't calculate it because the line might not be straight) but we can force it to be zero by shifting all the x,y coordinates by the same amount such that the first point is 0,0 now c=0 and we can calculate m for each point, m=y/x (except for the first point since this will result in divide by zero!)
If the line is straight then the value for m will be the same for each point. Should be relatively easy and quick to code...
Apathy Rules - I suppose...
|
|
|
|
|
hi..I'd like to ask if someone here know how can I convert 2dim.image to 3dim. image i.e.2d information to 3d information & how can I get patches of information for extraction images.In my project I use matlab.Thank you.
zz
|
|
|
|
|
Hi
Is it possible at all to convert 2d image data to 3d image data? In 2d image dat a you wont have the depth information, but for creating 3d image data you need depth information.
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|