Calculate geometry of Reference Point - revit-api

I have 4 placement points which I am using to create a outer panel. However, I have reference points which I want to use it for creating inner panel inside the outer panel. I have offset values available from each side of the outer panel. Now I want to calculate coordinates for the inner panel using Revit API/ geometry.
Any help would be greatly appreciated.

If you're asking to calculate new coordinates from coordinates and a specific offset, you're asking more of a Geometry question. http://www.purplemath.com has tons of great information about doing those calculations.
If it's always a set (x, y) offset you simply add, or subtract, the x-offset to the coordinate.x, and same for the y value. If it's anything other than 90 degrees, though, you'll need to start looking at the Y-Intercept Form and all that Geometry/Trigonometry math.

Related

VBA to check if object is inside or outside of freeform area

I need help with this : I have Freeform area and shapes in form of circles named from A to G. Some of this points are inside of Freeform area and some of them no. I need macro which will check each of this points - if this point is inside/ outside of freeform area. How can i get result in form of table where in Column A are Names of shapes (circles-points) and in column B result (if point is inside/outside of freeform).
Thanks
Victor
Picture of what I need is here:
There are several ways to do that. Either over calculation of the Angles or by creating a ray trough the point and find the intersections To the polygons. If the count are even, it's inside; if it's odd it's outside. Those algorithms are not that trivial and numerical a challenge. Here are some links (They have vb6/vba source):
Paul Bourke Point inside Polygon
VB-Helper Point inside Polygon
If it has not that exact you may draw the points in a picturebox and determine the background color.
To find more search the web for "points inside polygon".

Three.js calculate .obj size (bottom and top position.y)

How can I calculate object bottom position?
I created an object and a plane, both in (0,0,0) position, but the model geometrical center is placed in that point, not the bottom face of it, in result, the plane is clipping the half of it, see the demo: http://www.edar.com.pl/test-3d-3/
I'd like my models to have the same height when I place them on the screen. Also I want them all to intersect the shadow plane with their bottom parts, so I guess I have to calculate their heights and move them via object.position.y = obj_height/2; ?
Check Three.GeometryUtils.Center() - function which centers the geometry of an object.
So you could copy and modify the function to your liking to center the geometry at the bottom center.
Also you could also iterate over all vertices and just add or remove an offset-vector.

Gaps Between Rectangles Connected at the Center

I'm experimenting with a vector based graphics style with objects represented as series of line segments with a given width(it would probably be easier to think of these as rectangles). The problem is that these segments are connected at the center and leave a gap (shown below). I've determined that the most efficient way to cover this gap is simply to cover it with a triangle, and since I'm working in OpenGL, all I need are the points of the two points that don't overlap with the other rectangle, the third point being the center point where the two line segments(rectangles) are connected. How can I determine which points I need to use for the triangle, given that I have all of the points from both rectangles?
EDIT: I will also accept alternative solutions, as long as they cover up that gap.
EDIT 2: Nevermind, I solved it. I'll post code once I have better Internet connection.
Maybe I'm misunderstanding the question... but if you zoom in on the top corner of your red pentagon, you get something like this, am I right?
where A and B are nodes on the rectangle for edge1 and C and D are nodes on the rectangle for edge2. You say you already know these coordinates. And from what you say, the edges meet at the centre, which is halfway between A and B, and also halfway between C and D. So call this point X, and you can calculate its coordinates easily I guess.
So all you need to do is draw the missing triangle AXC, right? So one way would be to determine that A and C are on the "outside" of the polygon (and therefore need filling) and B and D are on the "inside" and therefore don't. But it's probably easier to just draw both, as it doesn't hurt. So if you fill AXC and BXD, you'd get this:
The solution I found assumes that there are 3 basic cases:
First, the three unique center points for the two rectangle proceed upward (positive y direction) so the gap is either on the left or right of the connection. In my code, I had the corner points of the rectangle organized by their orientation to the left or right of the center point, so if the bottom rectangle's left point is below the top rectangle's left point, then the gap is between the left points of the two rectangles, otherwise the gap is between the right points.
Second, the three unique center points have a maximum at the center most of the center points, so the gap is on the top. The gap is then between the two points with the maximum y values.
Third, the three unique center points have a minimum at the center most of the center points, so the gap is on the bottom. The gap is then between the two points with the minimum y values.
[I'll post pictures of the example cases if it is requested]

Corona SDK: Rotating an object with specific reference point consecutively

I'm trying to make a square move by rotating it sideways with its reference point set to the bottom side of the direction it is moving to.
For example: if I would move the square to the right, I would set its reference point to the bottom right of it and animate a rotation of 90 degrees, after the movement is done, I increase the square X by the width of it and centrally set its rotation to 90 degrees (so that I can keep track of its position)
The thing is, how should I proceed to keep repeating it? 'cause if I try to rotate by another 90 degrees using bottom right reference point, it won't be using the right position. What should I do to get the new bottom right relative position?
Thanks!
Create a transparent image twice as wide and high as the square.
Place the square in the top left corner.
Rotating the image around its center will now rotate the square in the way you describe.
You will need some maths to track where the new bottom is, using some simple formula for 2D rotation, so you calculate BEFORE rotating, where the point you wish to modify.
Then you use xReference and yReference variables :)

Finding a point clicked in a grid

Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.

Resources