Write a function in VB.Net that takes a point and a length as parameters and returns…
- User
Write a function in VB.Net that takes a point and a length as parameters and returns another point such that if a line were drawn between the points it would be at a 70 degree angle and of the length specified through the length parameter. We will call this function "GetPt". Then I want you to write a function that takes a graphics object, a starting point, a width, height and depth which it would then use to draw a cuboid. The cuboid would be drawn by first drawing a rectangle who's upper left corner is the starting point specified by the parameter. The width and height of this rectangle would be determined by the width and height parameters. Then we would draw a line for each corner of the rectangle using the GetPt function from earlier to get the second point, passing the depth as the length to the GetPt function. Finally we would draw a second rectangle whose corners would be the points returned by the calls to GetPt.
- Assistant
Here is the implementation of the "GetPt" function in VB.Net:
vbnetPublic Function GetPt(ByVal point As Point, ByVal length As Integer) As Point Dim x As Integer = point.X + (length * Math.Cos(70 * Math.PI / 180)) Dim y As Integer = point.Y + (length * Math.Sin(70 * Math.PI / 180)) Return New Point(x, y) End FunctionAnd here is the implementation of the "DrawCuboid" function in VB.Net:
vbnet - User
Rewrite both functions to use floating point data types instead of integers.
- Assistant
Here is the updated implementation of the "GetPt" function using floating point data types:
vbnetPublic Function GetPt(ByVal point As PointF, ByVal length As Single) As PointF Dim x As Single = point.X + (length * Math.Cos(70 * Math.PI / 180)) Dim y As Single = point.Y + (length * Math.Sin(70 * Math.PI / 180)) Return New PointF(x, y) End FunctionAnd here is the updated implementation of the "DrawCuboid" function using floating point data types:
vbnet