Distance between a point/vector and a fracture

Hello everyone,

I want to find all nodes/points or vectors (positions) inside my fracture (distance = 0). When I use fracture.position, I only get the center vector, but I don’t want to compare the center of the fracture with the positions. I want to find all points inside the fracture area. I tried using fracture.gintersect, but I want to evaluate each point individually, not as a set. How can I do this? I appreciate your time in answering my question.

There is no easy way to do this. You could Google how to calculate the distance from a point to a circle in 3D and try to implement something …

Here is my best attempt. Not fully tested, but seems to work for simple cases

model new

model domain extent -10 10

fracture create dip 0 dip-dir 0 pos 0 0 0 size 1

fish def get_distance(point)

  ; find fracture - ID 1
  frac = fracture.find(1)

  ; get normal, radius and center
  norm = fracture.norm(frac)
  rad = fracture.diam(frac)*0.5
  cen = fracture.pos(frac)

  ; assume some tolerance: 1e-6*radius
  tol = 1e-6*rad

  ; vector from center to point
  V = point - cen

  ; project P onto the plane of the fracture
  Q = point - norm*math.dot(norm,V)

  ; is projected point in the center?
  ; all points on the circle are equally close
  if math.mag(Q - cen) < tol
    if math.abs(math.dot(norm,V)) > 1-tol
      return math.mag(V)  ; point is over the center
    else
      io.out(‘this might be incorrect’)
      return  math.sqrt(math.mag(V)^2 - rad^2)
    endif
  endif

  ; find closest point on the circumference
  R = V - Q*rad/math.mag(Q)
  return math.mag(R + cen)
end

[get_distance(vector(2,0,2))])

[check = math.mag(vector(2,0,2) - vector(0.5,0,0))]
1 Like