I would like to split the 2D vector field along the edge of two materials in its tangential and normal parts.
The normal and tangential vectors on the lower material I did get with following filters: 1) Threshold, 2) Extract Surface, 3) Feature Edges and lastly with a 4) Programmable Filter. You can see the vectors in yellow.
Now, I need to apply the dot product between the vector field (red electric field) and the tangential vector. But only along the line, which separates the the two materials.
I would appreciate any help of decomposing the red vector field in its normal and tangential components along the edge between the blue and red material.
Still struggling and would love to get to the next step.
Thank you for your answer.
Sorry, my question was not so clear.
Let me try it again:
My programmable filter does calculate the normal and tangential vectors of the red surface:
from vtk.numpy_interface import algorithms as algs
import numpy as np
input0 = inputs[0]
numCells = input0.GetNumberOfCells()
normx = np.empty(numCells, dtype=np.float64)
normy = np.empty(numCells, dtype=np.float64)
normz = np.zeros(numCells, dtype=np.float64)
tangx = np.empty(numCells, dtype=np.float64)
tangy = np.empty(numCells, dtype=np.float64)
tangz = np.zeros(numCells, dtype=np.float64)
for i in range(numCells):
cell = input0.GetCell(i)
p1 = input0.GetPoint(cell.GetPointId(0))
p2 = input0.GetPoint(cell.GetPointId(1))
normx[i] = -(p2[1] - p1[1]) # Reverse the direction
normy[i] = (p2[0] - p1[0]) # Reverse the direction
# Calculate the magnitude of the vector
magnitude = np.sqrt(normx[i]**2 + normy[i]**2 + normz[i]**2)
# Normalize the vector components
if magnitude != 0:
normx[i] /= magnitude
normy[i] /= magnitude
normz[i] /= magnitude
tangx[i] = normy[i] # Reverse the direction
tangy[i] = -normx[i]
# Create the normalized vectors
norm_normalized = algs.make_vector(normx, normy, normz)
output.CellData.append(norm_normalized, "normals")
tang_normalized = algs.make_vector(tangx, tangy, tangz)
output.CellData.append(tang_normalized, "tangentials")
In order to get the scalar projection of my “electric field” data with the tangential vector, I would need to calculate proj = np.dot(“electric field”, tang_normalized) and the plot proj as a Line Chart.
I do not understand how to get access to my “electric field” data inside the Programmable Filter to finally apply the dot product ???