"Richard" <some_email@[EMAIL PROTECTED]
> wrote in message
news:5q8gadFu7apkU1@[EMAIL PROTECTED]
>
> "Dieter Hansen" <dieter.hansen@[EMAIL PROTECTED]
> wrote in message
> news:473f064c$1@[EMAIL PROTECTED]
>> Richard schrieb:
>> 1. define your line segment (most likely using point1 and point2)
>> 2. define your ray (most likely using an origin and a direction)
>> 3. calculate the intersection point between line segment and ray
>> 4. create 2nd ray (the reflection ray)
>> a. with the calculated intersection point as origin
>> b. the direction can be calculated using the law of reflection
>> (basically this equation R = 2 · N ·(N dot -D)+D ; where R is the
new
>> direction, N the normal of the line segment and D the incoming ray
>> direction)
>>
>>
>> **** till here this is all mathematically and no drawing involved ****
>>
>> 5. draw your line segment
>> 6. draw the first ray from its origin to the intersection point
>> 7. draw the second ray from its origin to an arbitrary point in the ray
>>
>> Regards
>> Dieter
>
> Dieter
> Thanks.
Let me see how far I can get with this, before I admit defeat. :c)
Remember
I've never programmed and I'm not a mathematician.
For a start, I'm assuming the source code will be relatively trivial and
that the application can be written in Visual Basic or perhaps Visual C#
and
that I can use the DOTNET 3 library, selecting the drawing methods
associated with GDI+. (I think my PC draws graphics using GDI+)
Instead of just a line, the actual requirement is to draw rectangles, and
for the ray to appear to reflect or bounce off the insides of the
rectangle a determined number of times.
When the application is made I want to input data associated with
something
like the following labels:
Rectangle Height (mm):
Rectangle Width (mm):
Ray Start Point Height (mm):
Ray Start Point Width (mm):
Ray Angle Start (Degrees):
Number of Ray Reflections:
And a Button named "TRACE!"
Of course the ray does not reflect off the sides of an actual physical
line
or surface. Whatever rectangle is drawn on the screen simply allows one
to put the ray into context. Anyway, I can see that it's mostly about the
ray, which of course will be a polyline. Indeed the ray could be shown
in a seperate window, but that rather defeats the objective, because I
want the ray to look as of it is reflecting off the insides of a
rectangle.
GDI+ draws the actual lines on the PC monitor or Form. As far as that is
concerned, I see there are a few drawing methods of significance
associated with VB or C# and DOTNET 3:
GRAPHICS CLASS
Draw line methods:
* DrawLine Method (Pen, Point, Point)
Draws a line connecting two Point structures.
e.Graphics.Drawline (blackPen, point1, point2)
Prior to drawing, there is a need to create a pen and points. Points
point1
and point2 are created using x and y coordinates for each point, (i.e.
each
point has a x and y associated with it in an ordered pair, as per:
Point1:(100,100); Point2:(500,500).
http://msdn2.microsoft.com/en-us/library/f956fzw1.aspx
* DrawLine Method (Pen, Int32, Int32, Int32, Int32)
Draws a line connecting the two points by the coordinate pairs.
e.Graphics.Drawline(blackPen, x1, y1, x2, y2)
Prior to drawing, there is a need to create a pen and establish
coordinates.
The four coordinates are created by simply entering an integer as per: x1=
100; y1=100, x2=500,y2=500.
http://msdn2.microsoft.com/en-us/library/xckcwxsa.aspx
* DrawLine Method (Pen, PointF, PointF)
Draws a line connecting two PointF structures.
e.Graphics.drawLine9blackpen, point1, point2)
I don't believe I need to use Floating Point.
http://msdn2.microsoft.com/en-us/library/021a23yy.aspx
* DrawLine Method (Pen, Single, Single, Single, Single)
Draws a line connecting the two points by the coordinate pairs.
e.Graphics.DrawLine (blackPen, x1, y1, x2, y2)
I don't believe I need to use Floating Point.
http://msdn2.microsoft.com/en-us/library/x6bezf2k.aspx
-----------
Draw lines method:
* DrawLines Method (Pen, Point[])
Draws a series of line segments that connect an array of Point structures.
e.GraphicsDrawLines(blackPen, points)
Prior to drawing, there is a need to create a pen and create an array of
point segements of the line. The points/segments are created using x and y
coordinates for each point, as per:
New Point (10,10)
New Point (10,100)
New Point (200,50)
New Point (250, 300)
http://msdn2.microsoft.com/en-us/library/7ewkcdb3.aspx
* DrawLines Method (Pen, PointF[])
Draws a series of line segments that connect an array of PointF
structures.
e.GraphicsDrawLines(blackPen, points)
http://msdn2.microsoft.com/en-us/library/83k7w0zx.aspx
I don't believe I need to use Floating Point.
----------
Draw rectangle methods:
* DrawRectangle Method (Pen, Rectangle)
Draws a rectangle by a Rectangle structure.
e.Graphics.DrawRectangle(blackPen, rect)
Prior to drawing, there is a need to create a pen and a rectangle. The
rectangle part consists of a top left-hand corner point, established by an
ordered pair of x and y coordinates and width and height,as per: Rect
(0,0,200,200).
http://msdn2.microsoft.com/en-us/library/sx8yykw8.aspx
* DrawRectangle Method (Pen, Int32, Int32, Int32, Int32)
Draws a rectangle specified by a coordinate pair, a width and a height.
e.GraphicsDrawRectangle(blackPen, x, y, width. height)
Prior to drawing, there is a need to create a pen and a location and size
of
a rectangle. The rectangle part consists of a top left-hand corner point,
established by an ordered pair of x and y coordinates and width and height
as per: x= 0. y=0. Width=200. Height=200.
http://msdn2.microsoft.com/en-us/library/x6hb4eba.aspx
* DrawRectangle Method (Pen, Single, Single, Single, Single)
Draws a rectangle specified by a coordinate pair, a width, and a height.
e.Graphics.DrawRectangle(blackPen, x, y, height)
I don't believe I need to use Floating Point.
http://msdn2.microsoft.com/en-us/library/x3z45zt7.aspx
----------
The above represent the tools that can be used to actually draw the lines
or
rays.
Now, I suppose I could simply stick to the DrawLines Method for
everything.
Or perhaps when I draw my rectangles I should use DrawRectangles.
So far, any numbers entered relate to pixels, not mm.
As yet I have not seen anything that talks about entering data as an
angle,
rather than a coordinate or integer. I want to specify the start ray angle
in degrees.
That array stuff is key I think.
If I need to use the floating point stuff, then please let me know.
At the moment I suppose I think I'm going to use DrawRectangle Method
(Pen,
Rectangle) to draw rectangles, and DrawLines Method (Pen, Point[]) for the
ray.
Of course; I'll need the use the Math class as well to calculate the data
for my "drawing tools".
http://msdn2.microsoft.com/en-us/library/system.math.aspx
Any useful comments appreciated. Thanks.


|