Now that the user interface for the concrete tool is up and running, I need to start working on the concrete analysis.

The first order of business is a meshing algorithm for the concrete shape. 

I do not know exactly which direction this meshing algorithm is going to head, but every direction I look, it appears as though I will need some code to check if a given point falls within an enclosed polygon. The pretty pictures above show the code in action, if the point falls within the polygon, it is painted green, if not, red.

After some research, it appeared as though the ray caster algorithm would be the ticket to solve this problem. 

The code to check if the point falls within any given abritary polygon is shown below:

function ray_casting(point, testPoly, holePolys) {
  var n = testPoly.length;
  var count = 0
  var holeCount = 0
  var x = point[0];
  var y = point[1];
  

for(var i=0; i <n; ++i) {
    if (i == n-1) {
      var side = {
        a: {
          x: testPoly[i][0],
          y: testPoly[i][1]
        },
        b: {
          x: testPoly[0][0],
          y: testPoly[0][1]
        }
      }
        var x1 = side.a.x
        var x2 = side.b.x
        var y1 = side.a.y
        var y2 = side.b.y
        if (y < y1 != y < y2 && x < (x2-x1)*(y-y1)/ (y2-y1)+x1) {
        count +=1
      }
    }
    else {
      var side = {
        a: {
          x: testPoly[i][0],
          y: testPoly[i][1]
        },
        b: {
          x: testPoly[i+1][0],
          y: testPoly[i+1][1]
        }
      }
      var x1 = side.a.x
      var x2 = side.b.x
      var y1 = side.a.y
      var y2 = side.b.y
      if (y < y1 != y < y2 && x < (x2-x1)*(y-y1)/ (y2-y1)+x1) {
        count +=1
      }
    }
  }
  for (var holePoly of holePolys) {
    var nHole = holePoly.length;
    for(var i=0; i <nHole; ++i) {
      if (i ==nHole-1){
        var side = {
          a: {
            x: holePoly[i][0],
            y: holePoly[i][1]
          },
          b: {
            x: holePoly[0][0],
            y: holePoly[0][1]
          }
        }
        var x1 = side.a.x
        var x2 = side.b.x
        var y1 = side.a.y
        var y2 = side.b.y
        if (y < y1 != y < y2 && x < (x2-x1)*(y-y1)/ (y2-y1)+x1) {
          holeCount +=1
        }
      }
      else{
        var side = {
          a: {
            x: holePoly[i][0],
            y: holePoly[i][1]
          },
          b: {
            x: holePoly[i+1][0],
            y: holePoly[i+1][1]
          }
        }
        var x1 = side.a.x
        var x2 = side.b.x
        var y1 = side.a.y
        var y2 = side.b.y
        if (y < y1 != y < y2 && x < (x2-x1)*(y-y1)/ (y2-y1)+x1) {
          holeCount +=1
        }
      }
    }
  }
  if (count % 2 == 0 || count == 0 ) {
    return [false, count, holeCount]
  }
  else if (holeCount % 2 == 1) {
    return [false, count, holeCount]
  }
  else {
    return [true, count, holeCount]
  }
}

The algorithm is very simple, given a point, cast an inifinite line to the right. If the line crosses the polygon an even number of times, the point is outside the polygon.

Adding in some more code to test for holes and we are able to quickly tell if the point is inside or outisde the polygon with holes.

The code can be found on github.

A tease for the future:

Reinforced Concrete Javascript

Our Sidebar

You can put any information here you'd like.

  • Latest Comments
  • retug on Transfer Diaphragm Design -

    @316Jq, The way I understand, the diaphragm design force (inertia force) per 12.10.1.1 is the inertia force.

    Using the blog example numbers let's say this is 1392 kips.

    The transfer diaphragm force could be estimated to be the delta in shears above and below the transfer level ~ (1500 -  …

  • 316Jq on Transfer Diaphragm Design -

    Just wonder how do you separate inertia force and the transfer force? The inertia force might be controlled by the Fpx,min per ASCE12.10-2,  while the transfer force might need to be multiplied by rho or omega. This is also briefly discussed in NHERP design guidance you used. 

  • retug on Section Cutter - ETABs Plugin -

    Hi Rodrigio, thanks for reaching out.

    My email is retug.austin@gmail.com, feel free to shoot me an email.

    The section cutter tool needs a bit of updating to work with the newer version of ETABs, but happy to discuss what you might have in mind for the add-in.

    Thanks