# Unique Problem

#### dan03uk

##### New Member

I am currently doing a study into the coverage of cancerous tumour using radiation beam lets.

What I the problem is that I am looking at tumours of different sizes in a 2D format. I will then need to cover the entire tumour with the minimum number of beam lets which I have managed to solve so far. My problem is creating something in excel that visually shows the different size tumours being covered by the different size beam lets.

I need to design a tumour that will change to the different size parameters I set and the same goes for the beam lets. I thought of using objects and writing a code in VBA. I think that’s quite easy.

Now to the hard part I then need to write a program that will cover the tumour with the beam lets, I wondered if there was some sort of vector/quordinates code you could use.

I am quite new to this VBA stuff, so I’m not sure if this is even possible any help would be very much appreciated.[/FONT]

### Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I'm not sure that Excel is the best platform for this application. The vector/coordinate terms that you want to use are .Left and .Top.

I've found these routines associated with a user defined Type Cartesian useful for calculating points on a plane.

Code:
``````Type Cartesian
x As Double
y As Double
End Type

Function Angle(aCart As Cartesian) As Double
Rem -Pi < Angle < Pi
Select Case True
Case Is = (aCart.x = 0)
Angle = Sgn(aCart.y) * Application.Pi() / 2
Case Is = (aCart.y = 0)
Angle = -(aCart.x < 0) * Application.Pi
Case Else
Angle = Atn(aCart.y / aCart.x)
If aCart.x < 0 Then
Angle = Angle + Sgn(aCart.y) * Application.Pi
End If
End Select
End Function

Function Rotate(aCart As Cartesian, rotationAngle As Double) As Cartesian
With Rotate
.x = aCart.x * Cos(rotationAngle) - aCart.y * Sin(rotationAngle)
.y = aCart.x * Sin(rotationAngle) + aCart.y * Cos(rotationAngle)
End With
End Function

Function cPlus(aCart As Cartesian, bCart As Cartesian) As Cartesian
cPlus.x = aCart.x + bCart.x
cPlus.y = aCart.y + bCart.y
End Function

Function cNeg(aCart As Cartesian) As Cartesian
With cNeg
.x = -aCart.x
.y = -aCart.y
End With
End Function

Function cCart(xVal As Double, yVal As Double) As Cartesian
cCart.x = xVal
cCart.y = yVal
End Function

Function cartString(aCart As Cartesian) As String
With aCart
cartString = "(" & .x & "," & .y & ")"
End With
End Function``````

I pushed SUBMIT before I got the chance to put add the demo routine that helps explain the syntax of using type Cartesian.
Code:
``````Sub Demo()
Dim crtA As Cartesian
Dim crtB As Cartesian
Dim crtC As Cartesian

crtA = cCart(1, 2)
crtB = cCart(2, 2)
crtC = cPlus(crtA, crtB)
MsgBox cartString(crtA) & "+" & cartString(crtB) & " = " & cartString(crtC)

End Sub``````
This project will be a bear of a way to learn VBA.

Replies
9
Views
1K
Replies
1
Views
737
Replies
1
Views
810
Replies
6
Views
945
Replies
3
Views
1K

1,196,152
Messages
6,013,754
Members
441,781
Latest member
Gian Carlos

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back