2
k - (-1) or 1 when they are 2 intersection points
5
#name : #DrGPointIntersectionItem,
6
#superclass : #DrGPointItem,
10
#category : #'DrGeoII-Core-Item'
13
{ #category : #'as yet unclassified' }
14
DrGPointIntersectionItem class >> newWith: theParents k: integer [
15
"Instantiate this mathItem with these parents
16
Parents contains other MathItem instance, sometime it contains other object as Point"
25
{ #category : #comparing }
26
DrGPointIntersectionItem >> = aMathItem [
27
^ super = aMathItem and: [k = aMathItem k]
30
{ #category : #'initialize-release' }
31
DrGPointIntersectionItem >> initialize: theParents [
32
"check for the right intersection point when one parent is a circle or an arc"
33
|pointA pointB clicPoint|
34
super initialize: theParents.
35
k := 0. "0 when only one intersection"
36
(theParents first isCircleItem
37
or: [theParents second isCircleItem
38
or: [theParents first isArcItem
39
or: [theParents second isArcItem]]])
41
pointA := [theParents first intersectionWith: theParents second flag: -1] on: Error do: [nil].
42
pointB := [theParents first intersectionWith: theParents second flag: 1] on: Error do: [nil].
43
pointA ifNil: [^ self k: 1].
44
pointB ifNil: [^ self k: -1].
45
clicPoint := theParents third.
46
(pointA squaredDistanceTo: clicPoint) < (pointB squaredDistanceTo: clicPoint)
51
{ #category : #'*DrGeoII-Core-testing' }
52
DrGPointIntersectionItem >> isConstrainedPointItem [
56
{ #category : #'*DrGeoII-Core-testing' }
57
DrGPointIntersectionItem >> isIntersectionPointItem [
61
{ #category : #accessing }
62
DrGPointIntersectionItem >> k [
66
{ #category : #accessing }
67
DrGPointIntersectionItem >> k: integer [
73
{ #category : #'xml writing' }
74
DrGPointIntersectionItem >> nodeType [
78
{ #category : #accessing }
79
DrGPointIntersectionItem >> parents: aCollection [
80
"We only need the 1st and 2nd mathItem in the collection.
81
The 3rd one is a Point instance (position the user clicked) only used at initialization time"
82
aCollection isEmptyOrNil ifTrue:
83
[parents := aCollection.
85
parents := OrderedCollection new
86
add: aCollection first;
87
add: aCollection second;
92
{ #category : #comparing }
93
DrGPointIntersectionItem >> rehash [
94
^hash := (super rehash bitXor: k ) bitXor: point hash
97
{ #category : #updating }
98
DrGPointIntersectionItem >> update [
100
self doParentsExist ifTrue:
101
[aPoint := [(parents first intersectionWith: parents second flag: k)] on: Error do: [nil].
103
ifNil: [exist := false]
106
self point: aPoint]].
109
{ #category : #'xml writing' }
110
DrGPointIntersectionItem >> writeAsXmlTo: aNode [
112
node := super writeAsXmlTo: aNode.