Ipoint Module

This module contains functions for operating on the IMOD point structure or for manipulating points within contours.

Header to include: ipoint.h


int imodPointAppend(Icont *cont, Ipoint *pnt)
int imodPointAppendXYZ(Icont *cont, float x, float y, float z)
int imodPointAdd(Icont *cont, Ipoint *pnt, int index)
int imodPointDelete(Icont *cont, int index)
void imodPointSetSize(Icont *cont, int pt, float size)
float imodPointGetSize(Iobj *obj, Icont *cont, int pt)
double imodel_point_dist(Ipoint *pnt1, Ipoint *pnt2)
float imodPointDistance(Ipoint *pnt1, Ipoint *pnt2)
float imodPoint3DScaleDistance(Ipoint *p1, Ipoint *p2, Ipoint *scale)
double imodPoint2DAngle(Ipoint *pt)
float imodPointLineSegDistance(Ipoint *lp1, Ipoint *lp2, Ipoint *p, float *tval)
float imodPointContDistance(Icont *cont, Ipoint *pt, int open, int threeD, int *closest)
float imodPointDot(Ipoint *pnt1, Ipoint *pnt2)
void imodPointCross( Ipoint *v1, Ipoint *v2, Ipoint *rp)
void imodPointNormalize(Ipoint *n)
int imodPointIsEqual(Ipoint *a, Ipoint *b)
int imodPointIntersect(Ipoint *a, Ipoint *b, Ipoint *c, Ipoint *d)
float imodPointArea(Ipoint *p1, Ipoint *p2, Ipoint *p3)
float imodPointAreaScale(Ipoint *p1, Ipoint *p2, Ipoint *p3, Ipoint *s)
int imodPointInsideCont(Icont *cont, Ipoint *pt)
int imodPointInsideArea(Iobj *obj, int *list, int nlist, float x, float y)
int makeAreaContList(Iobj *obj, int iz, int *list, int *nlist, int listSize)

int imodPointAppend(Icont *cont, Ipoint *pnt)

Adds point pnt to the end of contour cont.  Manages point sizes and labels correctly.  Returns number of points in contour, or 0 if an error occurs.

int imodPointAppendXYZ(Icont *cont, float x, float y, float z)

Adds the point x, y, z to the end of contour cont.  Manages point sizes and labels correctly.  Returns number of points in contour, or 0 if an error occurs.

int imodPointAdd(Icont *cont, Ipoint *pnt, int index)

Adds point pnt to contour cont at the given index.  Manages point sizes, labels, and general storage items correctly.  Returns number of points in contour, or 0 if an error occurs.

int imodPointDelete(Icont *cont, int index)

Deletes the point at index from contour cont.  Frees the point and size arrays if the only point is deleted, and manages point sizes, labels, and general storage items correctly.  Returns the size of the contour or -1 for error.

void imodPointSetSize(Icont *cont, int pt, float size)

Sets the size of point at pt in contour cont to size.  Creates a size array if necessary.

float imodPointGetSize(Iobj *obj, Icont *cont, int pt)

Returns the size of the point at pt in contour cont and object obj; if no size was set for his point it returns the default size for object.

double imodel_point_dist(Ipoint *pnt1, Ipoint *pnt2)

Returns distance in the X/Y plane between pnt1 and pnt2.

float imodPointDistance(Ipoint *pnt1, Ipoint *pnt2)

Returns distance in the X/Y plane between pnt1 and pnt2.

float imodPoint3DScaleDistance(Ipoint *p1, Ipoint *p2, Ipoint *scale)

Returns distance in 3D between points p1 and p2, with coordinates scaled by the values in scale.

double imodPoint2DAngle(Ipoint *pt)

Returns angle of line from origin to X, Y coordinates of pt, between -pi/2 and pi/2

float imodPointLineSegDistance(Ipoint *lp1, Ipoint *lp2, Ipoint *p, float *tval)

Returns the square of the distance between point p and the line segment between lp1 and lp2.  In tval, it returns the parameter specifying the position along the segment of the point of closest approach (between 0 at lp1 and 1 at lp2).

float imodPointContDistance(Icont *cont, Ipoint *pt, int open, int threeD, int *closest)

Returns the closest distance between the line segments in cont and point pt, or returns 0 for an empty contour or the distance to the single point in a one-point contour.  Set open non-zero for an open contour (i.e., to exclude the segment connecting end to start).  Set threeD non-zero to have the distances measured in 3D instead of in the X/Y plane.  Also returns in closest the index of the point at the beginning of the closest line segment.

float imodPointDot(Ipoint *pnt1, Ipoint *pnt2)

Returns dot product of pnt1 and pnt2.

void imodPointCross( Ipoint *v1, Ipoint *v2, Ipoint *rp)

Returns cross product of pnt1 and pnt2.

void imodPointNormalize(Ipoint *n)

Normalizes vector in n to length 1.

int imodPointIsEqual(Ipoint *a, Ipoint *b)

Returns 1 if point a equals point b, 0 otherwise.

int imodPointIntersect(Ipoint *a, Ipoint *b, Ipoint *c, Ipoint *d)

Returns 1 if the line segment between a and b intersects the line segment between c and d, 0 otherwise.

float imodPointArea(Ipoint *p1, Ipoint *p2, Ipoint *p3)

Returns the area of the 3D triangle formed by p1, p2, and p3

float imodPointAreaScale(Ipoint *p1, Ipoint *p2, Ipoint *p3, Ipoint *s)

Returns the area of the 3D triangle formed by p1, p2, and p3, with point coordinates scaled by s.

int imodPointInsideCont(Icont *cont, Ipoint *pt)

Returns 1 if the point pt is inside or on the contour cont, otherwise returns 0.  Uses the same code as in InsideContour.

int imodPointInsideArea(Iobj *obj, int *list, int nlist, float x, float y)

Tests whether the point x, y is inside any of the contours in object obj listed in list, where nlist is the number of entries in list.  If the point is inside a contour, it returns the contour number; otherwise it returns -1.

int makeAreaContList(Iobj *obj, int iz, int *list, int *nlist, int listSize)

Makes a list of the contours in object obj on the Z section closest to the Z value iz.  The contour numbers are returned in list and the number of contours in nlist.  listSize specifies the size of the list array.  Assumes the contours are planar and tests the Z value only of the first point.  Returns 1 if there are no contours in the object or -1 if there are more than listSize contours on the plane.