# Obtain the coordinates on the model through the two-dimensional plane drawing coordinates

I have a plan view of the model and some coordinates

For example,the coordinates of A1 are X=10 and Y=15, which means that A1 is 10 meters and 15 meters away from the top left corner of the drawing, respectively.
If it can be determined that the height of A1 is 3 meters, can the three-dimensional coordinates of A1 in the model be obtained from those informations?

Thanks!

Hello @619944680,

I believe that it would be possible to convert from 2D drawing space to 3D world space. In order for my suggestion to work, you will need to calculate the mid-point of your drawing in meters (consistent with the measurement unit you mentioned). It sounds like you can do this already since you are able to place certain points in the drawing. Essentially, we will be aligning the midpoint of the drawing in world coordinates to the midpoint in meters of your coordinates.

To calculate the midpoint of the drawing, we will go under the premise that the drawing is centered in the viewport when the drawing loads. To get the world coordinates of the midpoint, we can call this:

``````var canvasSize = hwv.view.getCanvasSize();
var midpoint = new Communicator.Point2(canvasSize.x / 2, canvasSize.y /2);
var worldMid = hwv.view.unprojectPoint(midpoint, 0);
``````

So now, letâ€™s say for example that the midpoint in meters in your coordinate system happens to be (30, 35). Youâ€™ll need to calculate a â€śtranslation factorâ€ť by dividing the `worldMid.x` and `worldMid.y` by the individual points of your midpoint in meters: `worldMid.x` / 30, `worldMid.y` / 35. Using your example, A1 (10, 15) would be converted to (10 * (`worldMid.x` /30), 15 * (`worldMid.y` / 35)) in world coordinates.

Also, it might be useful to â€śvisualizeâ€ť where the world origin is located. I believe this would typically be located at the bottom left-corner. You can run the following JavaScript to create a triangle at the world origin:

``````function createTriangleMeshData() {
const vertexData = [
0, 0, 0,
0, 10, 0,
10, 0, 0
];

const normalData = [
0, 0, 1,
0, 0, 1,
0, 0, 1
];

const polylineData = [
0, 0, 0,
0, 10, 0,
10, 0, 0
];

const meshData = new Communicator.MeshData();
meshData.setFaceWinding(Communicator.FaceWinding.Clockwise);
return meshData;
}

var triangleMeshData = createTriangleMeshData();
var triangleMeshId = await hwv.model.createMesh(triangleMeshData);

var meshInstanceData = new Communicator.MeshInstanceData(triangleMeshId);
meshInstanceData.setFaceColor(Communicator.Color.green());
meshInstanceData.setLineColor(Communicator.Color.blue());
meshInstanceData.setPointColor(Communicator.Color.black());
var node0 = hwv.model.createNode(hwv.model.getRootNode(),"node0")
var nodeId = await hwv.model.createMeshInstance(meshInstanceData, node0);
``````

A useful function to review is unprojectPoint which returns a world space point given a 2D screen space coordinate.

Hope this helps,
Tino

1 Like