nec2++ 2.1.1
Public Member Functions | Static Public Member Functions | List of all members
nec_wire Class Reference

A class to handle properties of wires. More...

#include <nec_wire.h>

Public Member Functions

 nec_wire (const nec_3vector &a, const nec_3vector &b, nec_float in_radius, int id)
 
nec_3vector parametrize (nec_float s) const
 
nec_float distance (const nec_3vector &a, const nec_3vector &b) const
 
nec_float length () const
 
int tag_id () const
 
nec_float get_radius () const
 
std::vector< nec_wireintersect (nec_wire &b)
 Calculate whether two wires intersect.
 
bool intersect (nec_3vector &b0)
 Calculate whether the point is inside the wire.
 
nec_float axis_distance (const nec_3vector &b0) const
 Measure how far a point lies from the wire axis.
 
bool similar (nec_wire &b)
 

Static Public Member Functions

static void int_solve (nec_3vector &a0, nec_3vector &a1, nec_3vector &b0, nec_3vector &b1, nec_float &distance, nec_float &sa, nec_float &sb)
 

Detailed Description

A class to handle properties of wires.

Examples
test_nec.c.

Member Function Documentation

◆ axis_distance()

nec_float nec_wire::axis_distance ( const nec_3vector &  b0) const
inline

Measure how far a point lies from the wire axis.

Parameters
b0The point being measured.
Returns
The distance from b0 to the nearest point of the axis, which is clamped to the wire's own extent so a point beyond an end measures from that end.

Referenced by intersect().

◆ int_solve()

static void nec_wire::int_solve ( nec_3vector &  a0,
nec_3vector &  a1,
nec_3vector &  b0,
nec_3vector &  b1,
nec_float &  distance,
nec_float &  sa,
nec_float &  sb 
)
inlinestatic

We use the following Mathematica expression to get the solution for the intersection of two cylinders. We set up the distance between the two center lines as d2

The equations are derived from sympy in the file intersections.py

d2 = (a0x - b0x + sa*(a1x - a0x) - sb*(b1x - b0x))^2 + (a0z - b0z + sa*(a1z - a0z) - sb*(b1z - b0z))^2 + (a0y - b0y + sa*(a1y - a0y) - sb*(b1y - b0y))^2;

soln = Solve[{D[d2,sa] == 0, D[d2,sb] == 0}, {sa,sb}]; Simplify[soln]

sa -> (2*a0x*(a0x - a1x) + 2*a0y*(a0y - a1y) + 2*a0z*(a0z - a1z) + 2*(-a0x \

  • a1x)*b0x + 2*(-a0y + a1y)*b0y + 2*(-a0z + a1z)*b0z + ((-4*(a0x^2 + a0y^2 + \ a1x*b0x - a0x*(a1x + b0x) + a1y*b0y - a0y*(a1y + b0y) + (a0z - a1z)*(a0z - \ b0z))*((a0x - a1x)*(b0x - b1x) + (a0y - a1y)*(b0y - b1y) + (a0z - a1z)*(b0z \
  • b1z)) + 4*((a0x - a1x)^2 + (a0y - a1y)^2 + (a0z - a1z)^2)*((a0x - \ b0x)*(b0x - b1x) + (a0y - b0y)*(b0y - b1y) + (a0z - b0z)*(b0z - \ b1z)))*(-2*(a0x - a1x)*(b0x - b1x) - 2*(a0y - a1y)*(b0y - b1y) - 2*(a0z - \ a1z)*(b0z - b1z)))/(-4*((a0x - a1x)*(b0x - b1x) + (a0y - a1y)*(b0y - b1y) + \ (a0z - a1z)*(b0z - b1z))^2 + 4*((a0x - a1x)^2 + (a0y - a1y)^2 + (a0z - \ a1z)^2)*((b0x - b1x)^2 + (b0y - b1y)^2 + (b0z - b1z)^2)))/(2*((a0x - a1x)^2 \
  • (a0y - a1y)^2 + (a0z - a1z)^2))

sb -> -((-4*(a0x^2 + a0y^2 + a1x*b0x - \ a0x*(a1x + b0x) + a1y*b0y - a0y*(a1y + b0y) + (a0z - a1z)*(a0z - b0z))*((a0x \

  • a1x)*(b0x - b1x) + (a0y - a1y)*(b0y - b1y) + (a0z - a1z)*(b0z - b1z)) + \ 4*((a0x - a1x)^2 + (a0y - a1y)^2 + (a0z - a1z)^2)*((a0x - b0x)*(b0x - b1x) + \ (a0y - b0y)*(b0y - b1y) + (a0z - b0z)*(b0z - b1z)))/(-4*((a0x - a1x)*(b0x - \ b1x) + (a0y - a1y)*(b0y - b1y) + (a0z - a1z)*(b0z - b1z))^2 + 4*((a0x - \ a1x)^2 + (a0y - a1y)^2 + (a0z - a1z)^2)*((b0x - b1x)^2 + (b0y - b1y)^2 + \ (b0z - b1z)^2)))

Referenced by intersect().

◆ intersect() [1/2]

bool nec_wire::intersect ( nec_3vector &  b0)
inline

Calculate whether the point is inside the wire.

Returns
true if the point x is inside the wire

References axis_distance().

◆ intersect() [2/2]

std::vector< nec_wire > nec_wire::intersect ( nec_wire b)
inline

Calculate whether two wires intersect.

Returns
A list of the wires that should be created.

References int_solve().


The documentation for this class was generated from the following file: