Great, i'd also be interested in a sample project!
Post
Replies
Boosts
Views
Activity
hi Dennis,
in lieu of getting a working solution, which I believe would answer this question, I am hoping you may be able to answer a question about the code you posted, per my understanding of building a 2D representation using the data from CapturedRoom.walls.
In a cartesian coordinate space, a wall would have, at a minimum, two points, with each point represented by an x and y value (which would be a single number). So a wall that is a 100 units long spanning 'left to right' would look like this (p is a wall point) [p:{x:0,y:0},p:{x:100,y:0}]
In a 2d space, in its simplest form, this wall would look like a horizontal line.
How do you map the data you show in your code to this type of cartesian data? I see you pulling out the x and y positions, and i see the span which i assume is the length, but how do you know which direction the line travels in cartesian space?
Sorry if this is a dumb question, I am just trying to distill down the code you thoughtfully provided to what I understand about 2D. Thanks
hi @denniswave, this is really cool - well thought through and executed. thanks for the guidance and repo!
quick question about scale and 'actual dimensions'. How does one acquire the real dimensions that are acquired by the lidar related processes on the device? I assume that the CapturedRoom surface objects store this in a unit of measure or format that can be converted easily to meters or feet/inches etc, but this is not clear in the code. I do see this in your constants:
let scalingFactor: CGFloat = 200
but I am not sure how the value 200 is related to the real world dimensions.
Ideally, I can take whatever unit of measure the device produces and scale it appropriately to units required on the system with which i integrate.
thanks!
Brent
hey guys, I ran into this same issue and was able to resolve it with excellent results. Dennis is right - but note that the solution depends on what you're attempting to accomplish and how you're managing the data.
I am exporting the data generated by room plan (in addition to the 2D data) to another app/platform. For the rotation use case, I take the longest continuous line, find its angle in radians, and then get the difference in radians relative to that line being horizontal (you can use 0, or Math.Pi or Math.Pi*2, etc - ... I am using javascript to do this btw). Once you have that delta in radians, you then rotate all points accordingly. It's important that I do this rotation before anything else, as I generate a ton of additional data that is derived from wall points.
Also, as a side note, I create wall depths, miters, faces, etc that make these walls much more than a thick drawn line. So I take the data that Dennis' process provides (essentially the midpoint of wall, its length and angle) and from there create two points to start from - the start and end points of the wall. For my purposes these endpoints make it easier to work from and to create the downstream data structures I require - and it makes it easier in my opinion to do things like rotate walls, but again, totally depends on your use cases.
@AnjaiNimale - per your question (as I eluded to above), if you're getting 'crosses' as a result, its likely that you are doing what I did when i first worked with the data, which is using the x and y position as a wall end point. Use it as a midpoint and find the start and end point using PointA and PointB. If you look at FloorPlanSurface, you'll see that these two points are derived from taking half the width of the wall and going in opposite directions. Confusing at first.
Brent
PS - i can try to pull out some javascript code for you, but its highly fragmented and it doesnt use any of the objects/properties that the RoomPlan or ARKit SDKs use, so i doubt it would be much help.
hi germolinal,
dumb question - how did you get the object serialized to json? Im looking at the api docs, but dont see anything obvious. thanks!