![]() |
【转帖】signs Of Coordinate Values
signs of coordinate values
signs of coordinate values i am writing a program that converts dwg coordinate data from one coordinate system to another (e.g., a mercator projection to latitude/longitude). my program reads the coordinates from the objects, performs the conversion, then updates the objects. for many files this works very well, but i have run into a file where the signs on the coordinate values are not what i expected. (i was unable to attach the file to this message, but i would be glad to send it via e-mail, if necessary.) when i look at this file in autocad, all of the coordinates fall within the range of about (2.84e+6, 7.15e+5) to (2.85e+6, 7.24e+5). when i look at the coordinate values of individual oddbpolyline objects using the odamfcapp, some of the coordinates have negative values, even though the extents of the object are positive. sometimes the x value is negative, and sometimes the y value is negative. needless to say, using these values as is causes my coordinate conversions to produce the wrong results. it appears that this only happens with oddbpolyline objects. other object types seem to have coordinate values that are positive. i assume that there is another piece of information that i need to take into account in order to make sure i am using the correct coordinate values as input to my coordinate transformation process. does anyone have any ideas as to what this might be? thanks. bob it's been a while since i started this thread, so i thought i would bump it up and add some more information to see if anyone has some answers. i've noticed that the elevation of the polyline seems to be involved. several of the polylines in the attached file have a negative elevation. when reading coordinates from those objects, the x coordinate of the point returned when i call oddbpolyline::getpointat(odgepolyline3d) differs from the x coordinate of the point returned when i call oddbpolyline::getpointat(odgepolyline2d). (the 2d point is the one that has the negative x coordinate.) when the elevation is positive, the x and y coordinates for the 2d and 3d points are the same. to illustrate this, i have attached a zip file containing a .dwg file where this problem occurs, and a modified exprotocolextension.cpp that i used in odreadex to compare the 2d and 3d values returned from the polylines. the 2d points in last polyline (handle 6de) have positive x coordinates, while all of the others have negative x coordinates. all of the x coordinates should be positive. this can also be seen by opening the file in odamfcappdll and looking a the polylines in the model_space block. my questions are: 1) is there something wrong with the .dwg file? i haven't found other files where this happens, so it seems possible that this is the case. 2) is the flipped sign on the 2d point something to be expected because of the negative elevation, and therefore, something i should account for in my code? 3) is this a bug in dwgdirect? i am using dwgdirect 2.6.3 with visual studio 2005. cheers, bob attached files (69.6 kb, 0 views) polyline entity has its object coordinate system (ocs). it's defined by polyline's normal. see odgematrix3d::worldtoplane() and planetoworld() methods. they return transformation matrices convertin between worl coordinate system (wcs) and ocs. polyline functions returning 2d geometry return it in ocs. polyline functions returning 3d geometry return it in wcs. even in 2d drawing ocs and wcs can be different if entity's normal is not (0,0,1) but (0,0,-1). sergey slezkin thanks for the information. it sounds like i should be performing the following steps to transform each point in a polyline (assumes simplest case where the polyline is made up entirely of line segments): code: // open polyline for write for (int i = 0; i < polyline-numverts(); i++) { odgepoint3d pt; polyline->getpointat(i, pt); // pt is in wcs coordinates odgepoint3d ptxf = // transform the wcs point // convert the transformed wcs point back to ocs odgepoint3d ocspt = ptxf.transformby(odgematrix3d::worldtoplane(polyline->normal())); // make a 2d point to update the polyline odgepoint2d ptout(ocspt.x, ocspt.y); polyline->setpointat(i, ptout); }does this look correct? should i be concerned with the oddbpolyline::isplanar() and oddbpolyline::getplane(), or can i just use the normal? cheers, bob last edited by bobc@bluemarblegeo.com; 3rd november 2008 at 11:57 amfff">. reason: fix code in example |
所有的时间均为北京时间。 现在的时间是 07:19 AM. |