View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default Maths-Integration

I know nuts about excel, not to mention its vba programming.

Hello. Just some thoughts. In the vba editor, you may want to add a
"Watch" to something like "ActiveSheet.Shapes(1)"
This way, when you are stepping thru your code, you can see what might be
available for your shape. It can be confusing, so this may help.

Also be aware that the coordinates that Excel uses on the sheet may be
different than what you expect. You may want to add a Unit Square, but the
coordinates that Excel uses on the sheet for each corner may be different.
This would give you a much larger "Area" in your calculations. I don't do
this often, but I "think" the Y axes scaling is different then the X axes
scaling. Maybe someone can jump in with some experience on that. I am not
sure if there is a way to convert Node points / Vertices back to the correct
"points" that the original user entered.

Here's a short demo to add a triangle, and uses the ".Vertices" property.
Notice that the extracted vertices are slightly different. I believe this
is due to rounding, and would affect your calculations also. Notice also
the ratio of 25/100 is slightly different then 24.75 / 99.75 that is stored.
All told, I don't think you will get an accurate reading of Area, etc.

Sub Demo()
Dim Shp(1 To 4, 1 To 2) As Single
Dim v

Shp(1, 1) = 25
Shp(1, 2) = 100

Shp(2, 1) = 100
Shp(2, 2) = 150

Shp(3, 1) = 150
Shp(3, 2) = 50

' Back to first point
Shp(4, 1) = 25
Shp(4, 2) = 100

ActiveSheet.Shapes.AddPolyline Shp

'// Now, get Vertices
v = ActiveSheet.Shapes(1).Vertices
Debug.Print v(1, 1); v(1, 2)
Debug.Print v(1, 1) / v(1, 2)
End Sub

Returns:
24.75 99.75
0.2481203

If you are doing many of these with double integrals, you may want to
consider a dedicated math program. It is difficult in Excel to do similar
things.

For example, if we make a Unit Pentagon...
shp = Pentagon;

we could ask for the vertices...

Vertices[shp]

{(1/4)*(-1 + Sqrt(5)),(1/2)*Sqrt((1/2)*(5 + Sqrt(5)))},
{(-(1/4))*(1 + Sqrt(5)),(1/2)*Sqrt((1/2)*(5 - Sqrt(5)))}
...etc

And calculate it's area...
Area[shp]
(5*(1 + Sqrt(5)))/(4*Sqrt(2*(5 - Sqrt(5))))

HTH
Dana DeLouis


"cigarette " wrote in message
...
Dear all, would appreciate if anyone can help me with this

I know nuts about excel, not to mention its vba programming.

I am trying to write a program using excel to calculate geometrical
properties of any arbitrary shape, namely perimeter, enclosed area
etc...I have several queries about how to start, listed as below :

1) the user to draw the shape required, either by autoshapes or any
other means, but the important thing is that i need the program to
capture the points that the user has clicked, for reference as
co-ordinate points. From here i can do vector calculus to work out the
perimeter, using the function { INTEGRAL F(r) dr}(*ignore this function
if not sure*). But how do i program it (vba)?

2) Subsequently using the points captured i need to perform various
integrations again to obtain the other properties. The Main problem is
how to get the program to perform integration? Bear in mind that some
of these calculations includes double integrals.

I know that this may be tough if you do not have mathematics knowledge,
but i will greatly appreciate if anyone can help with the 2 problems
listed. That is, (1) how to capture the points, (2) perform
mathematical integration. :(

Please try to help me, thanks in advance


---
Message posted from http://www.ExcelForum.com/