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

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".

Related

How to use different colors for two rectangle and how to set distance between those two rectangles to zero?

I tried to give each rectangle a different color but unfortunately it did not work
I want the horizontal distance between those two rectangles to be zero
Here is what I want:
And here is the code and result: http://www.plantuml.com/plantuml/uml/rP9FIyD04CNl-ocMUXEAIMn198PYeE1PZu9iacawT3CRPgSjMlpkhfiISoXuyEISNjuly-V1hhmObdrdbTyXzOPDfviUzI999exVciOTaLgzCTR3X5IcthNizjJKpZhMmePyG42YrEG_XbeCjHRqIUbGiQLqJC0wNKRhMO31oNiFQqTInd5NbGqB8hveFexhpsWTQs2E6-2pdoJBzAvKwZDSzNFBBFVu0VTPLhoWXEyql_asYbSQG5hacx1MnsmFnoqA54W7z5XPc1-01MjZvo5mZTIEpM-X_ZZYMZy9T3eTLJQgszdfjnpPlyWngiK5jHnIhe2Qy3g_0000
but the most important thing to set the horizontal distance between these two rectangle to zero
It's not possible to do a 0 horizontal distance between two rectangles in PlantUML. You could do a table in Creole, but it won't look like your example, since the lines (rows) would be aligned in a table.
When I see your usage, I think you'd be better off using DOT (GraphViz). You can wrap DOT code in #startdot/#enddot in a PlantUML engine and it will draw the diagram. For example:
https://www.plantuml.com/plantuml/uml/TP1HIyCm58NVyol2_GDJvfj9MDkK8PIbn88FOm_PShN5q9OqeY3-TvDfApBMXzwSd2_dmDrCmVXWXq1iz-BDsD8f-BTJcEWdeV7h1ujqFxLcH3uwq_K1Fy8XMR_WckwTEQBZZB0cowkIvahBKdEu0LgKLJNBsn_vM6V5mswxs7KcvLdV0SstXQfKP7KfGSGIrkWqqa5IhPxYuns7DOWMdHjOhbVYVV3EibKZ_y0Oie37sOfJNqGkXMFNlu8udU5ar4et75hq2CBEjmAlX5tMFlydup-jHeZ3FVaY6-njtFWt
But, since you're writing lower-level DOT, you need to use that syntax to lay everything out. There is much more control, but it's no longer PlantUML.

Is there a way to transform rectangle into any shapes in MS Excel?

In MS Excel, I applied conditional formatting to a cell A1 so that it's color changes from blue at value 0 and red at value 100. I copied that cell and pasted it as linked picture(I) specially.(Paste Special). The color of the rectangle picture now changes if value in original cell is changed. The problem is, the shape is only rectangular, it can be converted into square and diamond shape at best.If same rectangle can be transformed into different shapes(maybe by adding extra anchor on rectangle shape), a heat map can be created easily. Please share your insights about this thing if there is a way.
Following pictures may help understand the problem:
[Example][1]
If you want a heat map, please consider using a CHART not gazillions of picture objects, colored/placed/rotated/etc to ... mimic a chart.
First, google anything about "surface chart" in Excel, see how it looks in Excel, whatever. Just see it and think about it so you can compare it to your current approach.
You will observe some things, like:
it's 3D
it has just a few layers/colors
etc.
But really, all of them can be solved. Probably easier than your current approach.
you can easily turn off both axes and you can rotate it so the camera is totally straight top-down - then it looks flat as paper and noone can see it as 3D anymore
you can add more layers, you can set each of them to specific colors
etc.
Some resources:
multiple colors in surface chart
how to change rotation of 3d chart
geesh, I just found even a whole article/tutorial dedicated to creating heat map charts.
Please, read that last link and I'm pretty sure you will want to use that approach instead of doing picture puzzles.

Calculate geometry of Reference Point

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.

SVG Paths detect overlapping or enclosed shapes

I have brown filled svg paths and i want to detect and alert my user if there is any shape behind or above another shape. I know intersection list gets if they intersect at the edges but what happens if i want to detect a shape that is behind another shape but doesnt intersect at the edges?
The encoluseList method seems to be dealing with bounding boxes and not this.
Any ideas?
To detect if a path/shape overlaps another
1. Calculating the area covered by the final shape achieved
2. Calculating the sum of areas of all the shapes independently(since this is SVG and the details of each path element is known, this can be done)
3. Comparing the 2 areas.If the 2 areas are the same, then there is no overlapping otherwise at least 2 shapes overlap.
The tricky step is step 1 which can be approximately calculated using pixel painting algorithm(my preference). For other methods, you can go through the following stackoverflow question concerning area of overlapping circles

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