<< Chapter < Page Chapter >> Page >
  • GM01.Point3D.draw
  • GM01.Vector3D.draw
  • GM01.Line3D.draw

The method named GM01.Point3D.draw

Recall that a point simply represents a location in space and has no width, height, or depth. Therefore a point is not visible to the human eye.However, it is sometimes useful to draw a small circle around a point to mark its location for human consumption. That is the purpose of the draw method of the GM01.Point3D class, which is shown in its entirety in Listing 4 .

Listing 4 . The method named GM01.Point3D.draw.
public void draw(Graphics2D g2D){//Get 2D projection coordinate values. ColMatrix2D temp = convert3Dto2D(point);drawOval(g2D,temp.getData(0)-3, temp.getData(1)+3,6, 6);}//end draw

Purpose of the method

This method draws a small circle around the location of a point in 3D space. The 3D location of the circle is projected onto the 2D plane of the specifiedgraphics context for display later on a 2D screen. The code in Listing 4 projects that location in 3D space onto the 2D plane by calling the staticmethod named convert3Dto2D .

Behavior of the GM01.Point3D.draw method

The location of a point in 3D space, as represented by an object of the GM01.Point3D class, is actually stored in an object of the GM01.ColMatrix3D class. A reference to that ColMatrix3D object is stored in the instance variable named point belonging to the Point3D object. This reference is passed as a parameter to the convert3Dto2D method in Listing 4 .

Recall from Listing 1 that the convert3Dto2D method receives an incoming reference to an object of the class GM01.ColMatrix3D and returns a reference to an object of the class GM01.ColMatrix2D , which contains the horizontal and vertical components of the projection of the 3D point onto a2D plane.

Using the returned GM01.ColMatrix2D object

Listing 4 uses the horizontal and vertical components stored in the returned ColMatrix2D object to construct the proper parameters and call the wrapper method named GM01.drawOval . This wrapper method doesn't know that it is receiving parameters that were originally derived from an objectin 3D space. The world of the wrapper method is confined to 2D space. The wrapper method named GM01.drawOval performs the following actions:

  • casts the four incoming numeric parameters to type int ,
  • flips the sign on the vertical component to resolve the issue regarding the positive value for the y-axis, and
  • passes the parameters to the drawOval method of the standard Graphics class to cause a small circle to be drawn at the correct location on the 2D off-screen image.

The small circle is not converted to an ellipse

Note that even though the location of the point in 3D space is projected onto the 2D plane, the shape of the small circle is not converted to an ellipse toreflect the 3D to 2D conversion nature of the operation. Thus, if the circle were large, it wouldn't necessarily look right. However, in thiscase, the only purpose of the circle is to mark the location of a point in 3D space. Therefore, I didn't consider the actual shape of the marker to betoo important. Figure 1 shows examples of circles marking points in 3D space at the corners of the box and at the ends of the axes.

Questions & Answers

a perfect square v²+2v+_
Dearan Reply
kkk nice
Abdirahman Reply
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
Kim Reply
or infinite solutions?
Kim
y=10×
Embra Reply
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
Nancy Reply
rolling four fair dice and getting an even number an all four dice
ramon Reply
Kristine 2*2*2=8
Bridget Reply
Differences Between Laspeyres and Paasche Indices
Emedobi Reply
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
Mary Reply
is it 3×y ?
Joan Reply
J, combine like terms 7x-4y
Bridget Reply
im not good at math so would this help me
Rachael Reply
how did I we'll learn this
Noor Reply
f(x)= 2|x+5| find f(-6)
Prince Reply
f(n)= 2n + 1
Samantha Reply
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
bamidele Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask