Dot product of Plane and Point?

Is there a Dot product for planes in Python?

I have a list of 283500 Points and I want to delete the Points that are on the negative side of a Plane.

I tried Plane.Dot§ but get the error “AttributeError: ‘Plane’ object has no attribute ‘Dot’”. Searching the manual, I do find a dot product for Vectors, but none for Planes.

How can I check if Point p is on the positive side of Plane P?

For completeness, here’s my code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.

import math
# tool H20.000 W50.000;
def BuildLines(Layer0, heights, plane):

	plan=Plane.ByOriginNormal(Point.ByCoordinates(-1,0,1), Vector.ByCoordinates(-1,0,1))

	allLayers=[]
	for i in range(len(heights[0])):
		thisLayer=[]
		for j in range(len(Layer0[0])):
			thisCurve=[]
			for k in range(len(Layer0[0][j])):
				p=Point.ByCoordinates(Layer0[0][j][k].X, Layer0[0][j][k].Y, heights[0][i])
				if(plan.Dot(p) < 0):
					thisCurve.append(p)
			thisLayer.append(thisCurve)
		allLayers.append(thisLayer)
	return allLayers

OUT=BuildLines(IN[0], IN[1], IN[2]);

You can check the dot product of the normal of the plane to a vector which moves from the origin of the plane to the point you want to compare.

1 Like

Projecting onto the plane by the plane’s normal will give you null for anything on the normal side of the plane. Inverted normal will give null for the non-normal side. You can use those nulls to fulter lists accordingly.

Great, but what is the syntax?

  plan=Plane.ByOriginNormal(Point.ByCoordinates(-1,0,1), Vector.ByCoordinates(-1,0,1))
  p=Point.ByCoordinates(Layer0[0][j][k].X, Layer0[0][j][k].Y, heights[0][i])
  if(plan.Project(p, Vector.ByCoordinates(0,0,1)) == null):
      thisCurve.append(p)

Gives an error: AttributeError: ‘Plane’ object has no attribute ‘Project’

No idea and I’m away from the office until Tuesday. Try finding the nodes in the library and use node to code to get the script directly.

Thank you, I got that to work :slight_smile:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.

import math
# tool H20.000 W50.000;
def BuildLines(Layer0, heights, plane):

	planeNormal = plane[0].Normal;
	allLayers=[]
	for i in range(len(heights[0])):
		thisLayer=[]
		for j in range(len(Layer0[0])):
			thisCurve=[]
			for k in range(len(Layer0[0][j])):
				p=Point.ByCoordinates(Layer0[0][j][k].X, Layer0[0][j][k].Y, heights[0][i])
				pointVector = Vector.ByCoordinates(plane[0].Origin.X-p.X, plane[0].Origin.Y-p.Y,plane[0].Origin.Z-p.Z) 
				res = planeNormal.Dot(pointVector) > 0
				if(res):	#drop points outside of plane
					thisCurve.append(p)
			if len(thisCurve) > 1:
				thisLayer.append(thisCurve)
		allLayers.append(thisLayer)
	return allLayers

OUT=BuildLines(IN[0], IN[1], IN[2]);
1 Like