how to calculate the projection area .

how to calculate the projection area .

wokeyiyognshenme
Advocate Advocate
3,093 Views
15 Replies
Message 1 of 16

how to calculate the projection area .

wokeyiyognshenme
Advocate
Advocate

how to calculate the projection area .

there are two rectangle。

the light vector is (x,y,z)

 

one rectangle is projected to another rectangle.

0 Likes
Accepted solutions (1)
3,094 Views
15 Replies
Replies (15)
Message 2 of 16

wokeyiyognshenme
Advocate
Advocate

阴影面积.jpg

0 Likes
Message 3 of 16

leeminardi
Mentor
Mentor

Your first goal is to create two 2d shapes that lie on a plane that is perpendicular to the light direction vector.  You can do this by multiplying the world coordinates of each point by a transformation or 3D rotation matrix.

 

You can get a description of the rotation matrix here. Note, for your task:

z0 = 0,0,-1   z1 = light ray vector

 

For example, point A in the light ray coordinate system would be:

 

pointAL = pointA * R    (R = the rotation matrix)

pointBL = pointB * R

 

To get the projection of these shapes onto the plane perpendicular to the light vector simply ignore the z coordinate!  For example,

pointAL2D = pointAL(x), pointAL(y), 0

 

 

Now that you have two 2D shapes you need to determine how they overlap.  You can do a web search for a solution or  consider creating two regions from the two 2D shapes and use the AutoCAD Boolean Intersect command to create a region of the overlap.

 

 

...

lee.minardi
0 Likes
Message 4 of 16

wokeyiyognshenme
Advocate
Advocate

so complicated。。。

could you please give some code ?

1、I only know the light vector3d, how to determine the light coordinates

 

VectorZ = the light vector3d

How to determin the VectorX and VectorY

 

2、mathmatic is diffcult. I don't understand mathematics  .I only can use the API.

 

3、 two regions from the two 2D shapes and use the AutoCAD Boolean Intersect  --- i know the API, i can do this.

0 Likes
Message 5 of 16

wokeyiyognshenme
Advocate
Advocate

EFGH is not perpendicular to the light vector.

 

so the intersect of 2 shape is not equal to the shadow。

0 Likes
Message 6 of 16

leeminardi
Mentor
Mentor

@wokeyiyognshenme wrote:

so complicated。。。

could you please give some code ?

1、I only know the light vector3d, how to determine the light coordinates

It is assumed that the light is far away (e.g., the sun) and therefore the light rays are parallel and you do not need the location of the light source.

 

VectorZ = the light vector3d  This is the direction of the light rays.

How to determin the VectorX and VectorY of what

 

2、mathmatic is diffcult. I don't understand mathematics  .I only can use the API.  Then perhaps you should not be trying to write code for this problem.  I assume you had an understanding of vector algebra and matrices.

 

3、 two regions from the two 2D shapes and use the AutoCAD Boolean Intersect  --- i know the API, i can do this.  Great.


 

lee.minardi
0 Likes
Message 7 of 16

leeminardi
Mentor
Mentor

@wokeyiyognshenme wrote:

EFGH is not perpendicular to the light vector.

 

so the intersect of 2 shape is not equal to the shadow。


I know that EFGH is not perpendicular to the light vector.  After you multiply EFGH world coordinates times the rotation matrix you will have 3D coordinates of EFGH in a coordinate system whose z direction is the direction of the light vector.  By ignoring the z coordinate of these coordinates you in effect, project the shapes onto the XY plane of the light vector coordinate system. In this system you have transformed the 2 shapes to 2D shapes that lie on the same plane.

lee.minardi
0 Likes
Message 8 of 16

wokeyiyognshenme
Advocate
Advocate

maytbe ,can use this API ??

Curve.GetProjectedCurve Method
Description
This function creates a new curve entity that is the result of projecting the curve parallel to projectionDirection onto the planeToProjectOn and returns it.


C#
public virtual Curve GetProjectedCurve(
Plane planeToProjectOn,
Vector3d projectionDirection
);

Plane planeToProjectOn Input plane onto which the curve is to be projected
Vector3d projectionDirection Input direction (in WCS coordinates) of the projection

0 Likes
Message 9 of 16

leeminardi
Mentor
Mentor

Do you have a link to the documentation for the function?  I'd like to see the format required to define the plane.

lee.minardi
0 Likes
Message 10 of 16

SEANT61
Advisor
Advisor

@leeminardi wrote:

Do you have a link to the documentation for the function?  I'd like to see the format required to define the plane.


There are several Methods (Overloaded)

https://help.autodesk.com/view/OARX/2020/ENU/?guid=OARX-ManagedRefGuide-__OVERLOADED_Plane_Autodesk_...

 

And the Curve.GetProjectedCurve Method:

AutoCAD 2020 Developer and ObjectARX Help | Curve.GetProjectedCurve Method | Autodesk


************************************************************
May your cursor always snap to the location intended.
Message 11 of 16

sahibdadkhan17
Community Visitor
Community Visitor

To find the projection area of one rectangle onto another using a light vector, use this simple rule:

Projected Area = Original Area × |(n₁ · v̂) / (n₂ · v̂)|

  • n₁ = normal of the first rectangle

  • n₂ = normal of the target rectangle

  • = light direction normalized

This works because projecting along a direction scales the area based on the cosine between the direction and each surface.

For quick number checks, tools like calcolo stipendio netto online free are handy for fast calculations while experimenting with values.

0 Likes
Message 12 of 16

essam-salah
Advisor
Advisor


ok, using the two functions @SEANT61   mentioned, here is the steps:
1- create two 3DPolylines from the giving two rectangles --> polyABCK, polyEFGH
2- define light perpendicular plane --> lightplane.
3- project polyABCK and polyEFGH on lightplane --> polyABCK2, polyEFGH2
4- get the intersection of polyABCK2, polyEFGH2 and create a 3DPolyline out of it --> polyShade1

then if you want the shaded area on  EFGH rectangle as in the picture you provided:
5- define plane using 3 points E,F and G --> planeEFGH
6- project polyShade1 into planeEFGH and create a 3DPolyline out of it --> polyShade2

now we have the shaded area but it might be larger than EFGH, if you want it as part of EFGH:
7- calc intersection area between polyShade2 and polyEFGH on planeEFGH --> hasedAreaAsPicture

0 Likes
Message 13 of 16

wokeyiyognshenme
Advocate
Advocate

wrong 

There are three scenarios: (1) Surface ABCD is behind Surface EFGH 。 ABCD does not block EFGH. (2) Surface ABCD is in front of Surface EFGH .--- it's OK. (3) Part of Surface ABCD is in front of Surface EFGH , while another part is behind it. However, the Curve.GetProjectedCurve method cannot distinguish the projection direction.

0 Likes
Message 14 of 16

SEANT61
Advisor
Advisor
Accepted solution

As I’m sure you are realizing, the process brings a high degree of complexity.  I got involved with it myself during this project:

Vector Rendering 

 

I probably would not have pursued that endeavor had realized all the issues up front.  As it was, I always thought I was close and just needed one last issue to resolve.  Something else always popped and some remain to this day.  I should also point out that I am only processing Directional (Parallel) light.  Point lights add yet more complexity.

 

Despite those issues, though, the project was/is very rewarding.  I'll do what I can to answer questions.  The true advantage with a new set of eyes on the problem is the possibility that a better approach is found.


************************************************************
May your cursor always snap to the location intended.
0 Likes
Message 15 of 16

florenceherry99
Community Visitor
Community Visitor

Calculating a projection area can depend on whether you're working with 2D geometry, 3D solids, or CAD entities, but the general approach is to project the object onto a plane and then measure the resulting area. In Autodesk workflows, accuracy often depends on the projection method and object type being used. I appreciate tools that simplify complex calculations as well, it is a good example for understanding salary, tax, and net income estimates in a clear and practical way.

0 Likes
Message 16 of 16

sahamanojtry
Community Visitor
Community Visitor

Projection area depends on the direction of the light vector and the plane where the second rectangle lies. I don’t think you can get the correct result from rectangle area alone. First project the 4 corner points of the first rectangle along the light vector onto the plane of the second rectangle, then you get a new 2D polygon on that plane. After that, calculate the overlap area between that projected polygon and the second rectangle.

So the basic steps are:

  1. Define the 4 vertices of rectangle A.
  2. Define the plane of rectangle B.
  3. For each vertex of A, cast a ray in the light direction.
  4. Find the intersection point of each ray with B’s plane.
  5. Convert those points into B’s local 2D coordinates.
  6. Clip the projected polygon against rectangle B.
  7. Calculate the final clipped polygon area.

If the light vector is parallel to the target plane, there may be no valid projection. For simple construction or measurement-related areas I usually use online calculators (ex. concrete block calculator), but for this kind of 3D projection you really need vector math and polygon clipping.

0 Likes